s/qmail 4.2.29a
Next generation secure email transport
Loading...
Searching...
No Matches
instcheck.c
Go to the documentation of this file.
1#include <sys/types.h>
2#include <sys/stat.h>
3#include <unistd.h>
4#include "logmsg.h"
5#include "exit.h"
6#include "hier.h"
7
8extern void hier();
9
10#define WHO "instcheck"
11
12void perm(char *prefix1,char *prefix2,char *prefix3,char *file,int type,int uid,int gid,int mode)
13{
14 struct stat st;
15
16 if (stat(file,&st) == -1) {
17 if (errno == ENOENT)
18 logmsg(WHO,0,WARN,B("file does nost exist:",prefix1,prefix2,prefix3,file));
19 else
20 logmsg(WHO,errno,WARN,B("unable to stat: ../",file));
21 return;
22 }
23
24 if ((uid != -1) && (st.st_uid != uid))
25 logmsg(WHO,0,WARN,B("file has wrong owner: ",prefix1,prefix2,prefix3,file));
26 if ((gid != -1) && (st.st_gid != gid))
27 logmsg(WHO,0,WARN,B("file has wrong group: ",prefix1,prefix2,prefix3,file));
28 if ((st.st_mode & 07777) != mode)
29 logmsg(WHO,0,WARN,B("file has wrong permissions: ",prefix1,prefix2,prefix3,file));
30 if ((st.st_mode & S_IFMT) != type)
31 logmsg(WHO,0,WARN,B("file has wrong type: ",prefix1,prefix2,prefix3,file));
32}
33
34void h(char *home,int uid,int gid,int mode)
35{
36 perm("","","",home,S_IFDIR,uid,gid,mode);
37}
38
39void d(char *home,char *subdir,int uid,int gid,int mode)
40{
41 if (chdir(home) == -1)
42 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
43 perm("",home,"/",subdir,S_IFDIR,uid,gid,mode);
44}
45
46void p(char *home,char *fifo,int uid,int gid,int mode)
47{
48 if (chdir(home) == -1)
49 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
50 perm("",home,"/",fifo,S_IFIFO,uid,gid,mode);
51}
52
53void c(char *home,char *subdir,char *file,int uid,int gid,int mode)
54{
55 if (chdir(home) == -1)
56 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
57 if (chdir(subdir) == -1)
58 logmsg(WHO,111,FATAL,B("unable to switch to: ",home,"/",subdir));
59 perm(".../",subdir,"/",file,S_IFREG,uid,gid,mode);
60}
61
62void z(char *home,char *file,int len,int uid,int gid,int mode)
63{
64 if (chdir(home) == -1)
65 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
66 perm("",home,"/",file,S_IFREG,uid,gid,mode);
67}
68
69int main()
70{
71 hier();
72 _exit(0);
73}
stralloc file
Definition: columnt.c:20
void _exit()
void c(char *, char *, char *, int, int, int)
Definition: install.c:57
void p(char *home, char *fifo, int uid, int gid, int mode)
Definition: instcheck.c:46
void hier()
Definition: hier.c:30
void h(char *home, int uid, int gid, int mode)
Definition: instcheck.c:34
void z(char *home, char *file, int len, int uid, int gid, int mode)
Definition: instcheck.c:62
#define WHO
Definition: instcheck.c:10
int main()
Definition: instcheck.c:69
ulongalloc uid
Definition: matchup.c:58
void perm()
Definition: qmail-inject.c:63
stralloc home
Definition: qmail-pw2u.c:98
struct del * d[CHANNELS]
Definition: qmail-send.c:720