10#define WHO "instcheck"
12static void perm (
char *prefix1,
char *prefix2,
char *prefix3,
char *file,
int type,
int uid,
int gid,
int mode)
16 if (stat(file,&st) == -1) {
17 if (
errno == error_noent)
18 logmsg(
WHO,-1,WARN,B(
"file: ",prefix1,prefix2,prefix3,file,
" does not exist"));
20 logmsg(
WHO,-1,WARN,B(
"unable to stat .../",file));
24 if ((uid != -1) && (st.st_uid != uid))
25 logmsg(
WHO,-1,WARN,B(
"file: ",prefix1,prefix2,prefix3,file,
" has wrong owner"));
26 if ((gid != -1) && (st.st_gid != gid))
27 logmsg(
WHO,-1,WARN,B(
"file: ",prefix1,prefix2,prefix3,file,
" has wrong group"));
28 if ((st.st_mode & 07777) != mode)
29 logmsg(
WHO,-1,WARN,B(
"file: ",prefix1,prefix2,prefix3,file,
" has wrong permissions"));
30 if ((st.st_mode & S_IFMT) !=
type)
31 logmsg(
WHO,-1,WARN,B(
"file: ",prefix1,prefix2,prefix3,file,
" has wrong type"));
34void h(
char *home,
int uid,
int gid,
int mode)
36 perm(
"",
"",
"",home,S_IFDIR,uid,gid,mode);
39void d(
char *home,
char *subdir,
int uid,
int gid,
int mode)
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);
46void p(
char *home,
char *fifo,
int uid,
int gid,
int mode)
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);
53void c(
char *home,
char *subdir,
char *file,
int uid,
int gid,
int mode)
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);
62void z(
char *home,
char *file,
int len,
int uid,
int gid,
int mode)
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);
void p(char *home, char *fifo, int uid, int gid, int mode)
void d(char *home, char *subdir, int uid, int gid, int mode)
void c(char *home, char *subdir, char *file, int uid, int gid, int mode)
void z(char *home, char *file, int len, int uid, int gid, int mode)