File: util.c

package info (click to toggle)
mush 7.2.5unoff2-6
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 1,664 kB
  • ctags: 1,329
  • sloc: ansic: 21,901; sh: 796; csh: 87; makefile: 72
file content (49 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Code by Yves Arrouye <arrouye@debian.org> */

#include "mush.h"

/* Return 1 if we think file is someone's sysspooldir, 0 otherwise. */

issysspoolfile(file)
    const char* file; {
#ifdef HOMEMAIL
    char* p;
#else
    int l;
#endif

    struct passwd* pwd;

    if (!strcmp(file, sysspoolfile)) return 1;

#ifdef HOMEMAIL
    p = rindex(file, '/');
    if (p) ++p; else return 0;

#ifdef POP3_SUPPORT
    if (strcmp(p, POPMAILFILE) && strcmp(p, MAILFILE)) return 0;
#else
    if (strcmp(p, MAILFILE)) return 0;
#endif

    while (*--p == '/');

    while ((pwd = getpwent()) != 0) {
	if (strlen(pwd->pw_passwd) < 3) continue;
	if (!strncmp(pwd->pw_dir, file, p - file + 1)) break;
    }
    endpwent();

    return pwd ? 1 : 0;
#else
    l = strlen(MAILDIR);
    return !strncmp(file, MAILDIR, l)
#ifdef DEL_NOUSER
	&& (pwd = getpwnam(file + l + 1)) && strlen(pwd->pw_passwd) > 2
#endif
	;
#endif /* HOMEMAIL */

return 0;
}