djbdnscurve6 45
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(prefix1,prefix2,prefix3,file,type,uid,gid,mode)
12char *prefix1;
13char *prefix2;
14char *prefix3;
15char *file;
16int type;
17int uid;
18int gid;
19int mode;
20{
21 struct stat st;
22
23 if (stat(file,&st) == -1) {
24 if (errno == ENOENT)
25 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," does not exist"));
26 else
27 logmsg(WHO,-99,WARN,B("unable to stat: .../",file));
28 return;
29 }
30
31 if ((uid != -1) && (st.st_uid != uid))
32 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong owner"));
33 if ((gid != -1) && (st.st_gid != gid))
34 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong group"));
35 if ((st.st_mode & 07777) != mode)
36 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong permissions"));
37 if ((st.st_mode & S_IFMT) != type)
38 logmsg(WHO,-99,WARN,B(prefix1,prefix2,prefix3,file," has wrong type"));
39}
40
41void h(home,uid,gid,mode)
42char *home;
43int uid;
44int gid;
45int mode;
46{
47 perm("","","",home,S_IFDIR,uid,gid,mode);
48}
49
50void d(home,subdir,uid,gid,mode)
51char *home;
52char *subdir;
53int uid;
54int gid;
55int mode;
56{
57 if (chdir(home) == -1)
58 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
59 perm("",home,"/",subdir,S_IFDIR,uid,gid,mode);
60}
61
62void p(home,fifo,uid,gid,mode)
63char *home;
64char *fifo;
65int uid;
66int gid;
67int mode;
68{
69 if (chdir(home) == -1)
70 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
71 perm("",home,"/",fifo,S_IFIFO,uid,gid,mode);
72}
73
74void c(home,subdir,file,uid,gid,mode)
75char *home;
76char *subdir;
77char *file;
78int uid;
79int gid;
80int mode;
81{
82 if (chdir(home) == -1)
83 logmsg(WHO,111,FATAL,B("unable to switch to: ",home));
84 if (chdir(subdir) == -1)
85 logmsg(WHO,111,FATAL,B("unable to switch to: ",home,"/",subdir));
86 perm(".../",subdir,"/",file,S_IFREG,uid,gid,mode);
87}
88
89void z(home,file,len,uid,gid,mode)
90char *home;
91char *file;
92int len;
93int uid;
94int gid;
95int mode;
96{
97 if (chdir(home) == -1)
98 logmsg(WHO,111,FATAL,B("unable to switch to; ",home));
99 perm("",home,"/",file,S_IFREG,uid,gid,mode);
100}
101
102int main()
103{
104 hier();
105 _exit(0);
106}
uint16 len
Definition: axfrdns.c:319
char * p
Definition: dnscache.c:37
char type[2]
Definition: dnsq.c:56
void c(const char *home, const char *subdir, const char *file, int uid, int gid, int mode)
void d(const char *home, const char *subdir, int uid, int gid, int mode)
void perm(char *prefix1, char *prefix2, char *prefix3, char *file, int type, int uid, int gid, int mode)
Definition: instcheck.c:11
void hier()
Definition: hier.c:7
void h(char *home, int uid, int gid, int mode)
Definition: instcheck.c:41
void z(char *home, char *file, int len, int uid, int gid, int mode)
Definition: instcheck.c:89
#define WHO
Definition: instcheck.c:9
int main()
Definition: instcheck.c:102
char mode
Definition: tinydns-edit.c:45