djbdnscurve6 46
djbdnscurve6
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
7extern void hier();
8
9#define WHO "instcheck"
10
11void perm(char *prefix1,char *prefix2,char *prefix3,char *file,int type,int uid,int gid,int mode)
12{
13 struct stat st;
14
15 if (stat(file,&st) == -1) {
16 if (errno == ENOENT)
17 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," does not exist"));
18 else
19 logmsg(WHO,-99,WARN,B("unable to stat: .../",file));
20 return;
21 }
22
23 if ((uid != -1) && (st.st_uid != uid))
24 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong owner"));
25 if ((gid != -1) && (st.st_gid != gid))
26 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong group"));
27 if ((st.st_mode & 07777) != mode)
28 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong permissions"));
29 if ((st.st_mode & S_IFMT) != type)
30 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong type"));
31}
32
33void h(char *home,int uid,int gid,int mode)
34{
35 perm("","","",home,S_IFDIR,uid,gid,mode);
36}
37
38void d(char *home,char *subdir,int uid,int gid,int mode)
39{
40 if (chdir(home) == -1)
41 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
42 perm("",home,"/",subdir,S_IFDIR,uid,gid,mode);
43}
44
45void p(char *home,char *fifo,int uid,int gid,int mode)
46{
47 if (chdir(home) == -1)
48 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
49 perm("",home,"/",fifo,S_IFIFO,uid,gid,mode);
50}
51
52void c(char *home,char *subdir,char *file,int uid,int gid,int mode)
53{
54 if (chdir(home) == -1)
55 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
56 if (chdir(subdir) == -1)
57 logmsg(WHO,111,FATAL,B("unable to switch to: ",home,"/",subdir));
58 perm(".../",subdir,"/",file,S_IFREG,uid,gid,mode);
59}
60
61void z(char *home,char *file,int len,int uid,int gid,int mode)
62{
63 if (chdir(home) == -1)
64 logmsg(WHO,111,FATAL,B("unable to switch to; ",home));
65 perm("",home,"/",file,S_IFREG,uid,gid,mode);
66}
67
68int main()
69{
70 hier();
71 _exit(0);
72}
#define WHO
Definition axfr-get.c:16
uint16 len
Definition axfrdns.c:319
char * p
Definition dnscache.c:37
char type[2]
Definition dnsq.c:56
void perm(char *prefix1, char *prefix2, char *prefix3, char *file, int type, int uid, int gid, int mode)
Definition instcheck.c:11
void d(char *home, char *subdir, int uid, int gid, int mode)
Definition instcheck.c:38
void c(char *home, char *subdir, char *file, int uid, int gid, int mode)
Definition instcheck.c:52
void hier()
Definition hier.c:7
void h(char *home, int uid, int gid, int mode)
Definition instcheck.c:33
void z(char *home, char *file, int len, int uid, int gid, int mode)
Definition instcheck.c:61
int main()
Definition instcheck.c:68
char mode