s/qmail 4.4.13
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 "str.h"
7#include "hier.h"
8
9extern void hier();
10extern void qmq_hier();
11
12#define WHO "instcheck"
13
14void perm(char *prefix1,char *prefix2,char *prefix3,char *file,int type,int uid,int gid,int mode)
15{
16 struct stat st;
17
18 if (stat(file,&st) == -1) {
19 if (errno == ENOENT)
20 logmsg(WHO,0,WARN,B("file does nost exist:",prefix1,prefix2,prefix3,file));
21 else
22 logmsg(WHO,errno,WARN,B("unable to stat: ../",file));
23 return;
24 }
25
26 if ((uid != -1) && (st.st_uid != uid))
27 logmsg(WHO,0,WARN,B("file has wrong owner: ",prefix1,prefix2,prefix3,file));
28 if ((gid != -1) && (st.st_gid != gid))
29 logmsg(WHO,0,WARN,B("file has wrong group: ",prefix1,prefix2,prefix3,file));
30 if ((st.st_mode & 07777) != mode)
31 logmsg(WHO,0,WARN,B("file has wrong permissions: ",prefix1,prefix2,prefix3,file));
32 if ((st.st_mode & S_IFMT) != type)
33 logmsg(WHO,0,WARN,B("file has wrong type: ",prefix1,prefix2,prefix3,file));
34}
35
36void h(char *home,char *queue,int uid,int gid,int mode)
37{
38 perm("","","",home,S_IFDIR,uid,gid,mode);
39}
40
41void d(char *home,char *subdir,int uid,int gid,int mode)
42{
43 if (chdir(home) == -1)
44 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
45 perm("",home,"/",subdir,S_IFDIR,uid,gid,mode);
46}
47
48void p(char *home,char *fifo,int uid,int gid,int mode)
49{
50 if (chdir(home) == -1)
51 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
52 perm("",home,"/",fifo,S_IFIFO,uid,gid,mode);
53}
54
55void c(char *home,char *subdir,char *file,int uid,int gid,int mode)
56{
57 if (chdir(home) == -1)
58 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
59 if (chdir(subdir) == -1)
60 logmsg(WHO,111,FATAL,B("unable to switch to: ",home,"/",subdir));
61 perm(".../",subdir,"/",file,S_IFREG,uid,gid,mode);
62}
63
64void z(char *home,char *file,int len,int uid,int gid,int mode)
65{
66 if (chdir(home) == -1)
67 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
68 perm("",home,"/",file,S_IFREG,uid,gid,mode);
69}
70
71int main(int argc,char * const argv[])
72{
73 if (argc == 2 && !str_diffn(argv[1],"qmq",3)) qmq_hier();
74 else hier();
75 _exit(0);
76}
int main()
Definition: chkshsgr.c:6
stralloc file
Definition: columnt.c:19
void _exit(int)
void c(char *, char *, char *, int, int, int)
Definition: install.c:70
void p(char *home, char *fifo, int uid, int gid, int mode)
Definition: instcheck.c:48
void perm(char *prefix1, char *prefix2, char *prefix3, char *file, int type, int uid, int gid, int mode)
Definition: instcheck.c:14
void qmq_hier()
Definition: hier.c:178
void hier()
Definition: hier.c:31
void z(char *home, char *file, int len, int uid, int gid, int mode)
Definition: instcheck.c:64
#define WHO
Definition: instcheck.c:12
void h(char *home, char *queue, int uid, int gid, int mode)
Definition: instcheck.c:36
ulongalloc uid
Definition: matchup.c:59
stralloc home
Definition: qmail-pw2u.c:99
struct del * d[CHANNELS]
Definition: qmail-send.c:726