cdb-full 0.5a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +6 -0
- data/FILES +88 -0
- data/README +163 -0
- data/VERSION +1 -0
- data/cdb-0.75/CHANGES +16 -0
- data/cdb-0.75/FILES +78 -0
- data/cdb-0.75/Makefile +320 -0
- data/cdb-0.75/README +7 -0
- data/cdb-0.75/SYSDEPS +3 -0
- data/cdb-0.75/TARGETS +66 -0
- data/cdb-0.75/TODO +1 -0
- data/cdb-0.75/VERSION +1 -0
- data/cdb-0.75/alloc.c +32 -0
- data/cdb-0.75/alloc.h +8 -0
- data/cdb-0.75/auto-str.c +44 -0
- data/cdb-0.75/auto_home.h +6 -0
- data/cdb-0.75/buffer.c +10 -0
- data/cdb-0.75/buffer.h +56 -0
- data/cdb-0.75/buffer_0.c +12 -0
- data/cdb-0.75/buffer_1.c +6 -0
- data/cdb-0.75/buffer_1s.c +6 -0
- data/cdb-0.75/buffer_2.c +6 -0
- data/cdb-0.75/buffer_copy.c +16 -0
- data/cdb-0.75/buffer_get.c +67 -0
- data/cdb-0.75/buffer_put.c +88 -0
- data/cdb-0.75/byte.h +13 -0
- data/cdb-0.75/byte_copy.c +14 -0
- data/cdb-0.75/byte_cr.c +16 -0
- data/cdb-0.75/byte_diff.c +16 -0
- data/cdb-0.75/cdb.c +136 -0
- data/cdb-0.75/cdb.h +37 -0
- data/cdb-0.75/cdb_hash.c +21 -0
- data/cdb-0.75/cdb_make.c +153 -0
- data/cdb-0.75/cdb_make.h +39 -0
- data/cdb-0.75/cdbdump.c +83 -0
- data/cdb-0.75/cdbget.c +67 -0
- data/cdb-0.75/cdbmake-12.sh +8 -0
- data/cdb-0.75/cdbmake-sv.sh +22 -0
- data/cdb-0.75/cdbmake.c +110 -0
- data/cdb-0.75/cdbstats.c +125 -0
- data/cdb-0.75/cdbtest.c +119 -0
- data/cdb-0.75/choose.sh +18 -0
- data/cdb-0.75/conf-cc +3 -0
- data/cdb-0.75/conf-home +3 -0
- data/cdb-0.75/conf-ld +3 -0
- data/cdb-0.75/error.c +109 -0
- data/cdb-0.75/error.h +25 -0
- data/cdb-0.75/error_str.c +271 -0
- data/cdb-0.75/exit.h +6 -0
- data/cdb-0.75/find-systype.sh +159 -0
- data/cdb-0.75/fmt.h +25 -0
- data/cdb-0.75/fmt_ulong.c +13 -0
- data/cdb-0.75/hier.c +15 -0
- data/cdb-0.75/install.c +149 -0
- data/cdb-0.75/instcheck.c +108 -0
- data/cdb-0.75/open.h +10 -0
- data/cdb-0.75/open_read.c +6 -0
- data/cdb-0.75/open_trunc.c +6 -0
- data/cdb-0.75/random.cdb +0 -0
- data/cdb-0.75/readwrite.h +7 -0
- data/cdb-0.75/rts.exp +251 -0
- data/cdb-0.75/rts.sh +1 -0
- data/cdb-0.75/rts.tests +210 -0
- data/cdb-0.75/scan.h +28 -0
- data/cdb-0.75/scan_ulong.c +11 -0
- data/cdb-0.75/seek.h +15 -0
- data/cdb-0.75/seek_cur.c +7 -0
- data/cdb-0.75/seek_set.c +7 -0
- data/cdb-0.75/str.h +14 -0
- data/cdb-0.75/str_len.c +14 -0
- data/cdb-0.75/strerr.h +78 -0
- data/cdb-0.75/strerr_die.c +31 -0
- data/cdb-0.75/strerr_sys.c +12 -0
- data/cdb-0.75/testzero.c +35 -0
- data/cdb-0.75/trycpp.c +7 -0
- data/cdb-0.75/tryulong32.c +11 -0
- data/cdb-0.75/uint32.h1 +11 -0
- data/cdb-0.75/uint32.h2 +11 -0
- data/cdb-0.75/uint32_pack.c +21 -0
- data/cdb-0.75/uint32_unpack.c +31 -0
- data/cdb-0.75/warn-auto.sh +2 -0
- data/cdb-0.75/x86cpuid.c +38 -0
- data/cdb.c +372 -0
- data/depend +1 -0
- data/extconf.rb +11 -0
- data/lib/cdb.rb +90 -0
- data/sample/sample.rb +35 -0
- metadata +152 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
# oper-:arch-:syst-:chip-:kern-
|
2
|
+
# oper = operating system type; e.g., sunos-4.1.4
|
3
|
+
# arch = machine language; e.g., sparc
|
4
|
+
# syst = which binaries can run; e.g., sun4
|
5
|
+
# chip = chip model; e.g., micro-2-80
|
6
|
+
# kern = kernel version; e.g., sun4m
|
7
|
+
# dependence: arch --- chip
|
8
|
+
# \ \
|
9
|
+
# oper --- syst --- kern
|
10
|
+
# so, for example, syst is interpreted in light of oper, but chip is not.
|
11
|
+
# anyway, no slashes, no extra colons, no uppercase letters.
|
12
|
+
# the point of the extra -'s is to ease parsing: can add hierarchies later.
|
13
|
+
# e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium,
|
14
|
+
# and i386-486 (486s do have more instructions, you know) as well as i386.
|
15
|
+
# the idea here is to include ALL useful available information.
|
16
|
+
|
17
|
+
exec 2>/dev/null
|
18
|
+
|
19
|
+
sys="`uname -s | tr '/:[A-Z]' '..[a-z]'`"
|
20
|
+
if [ x"$sys" != x ]
|
21
|
+
then
|
22
|
+
unamer="`uname -r | tr /: ..`"
|
23
|
+
unamem="`uname -m | tr /: ..`"
|
24
|
+
unamev="`uname -v | tr /: ..`"
|
25
|
+
|
26
|
+
case "$sys" in
|
27
|
+
bsd.os)
|
28
|
+
# in bsd 4.4, uname -v does not have useful info.
|
29
|
+
# in bsd 4.4, uname -m is arch, not chip.
|
30
|
+
oper="$sys-$unamer"
|
31
|
+
arch="$unamem"
|
32
|
+
syst=""
|
33
|
+
chip="`sysctl -n hw.model`"
|
34
|
+
kern=""
|
35
|
+
;;
|
36
|
+
freebsd)
|
37
|
+
# see above about bsd 4.4
|
38
|
+
oper="$sys-$unamer"
|
39
|
+
arch="$unamem"
|
40
|
+
syst=""
|
41
|
+
chip="`sysctl -n hw.model`" # hopefully
|
42
|
+
kern=""
|
43
|
+
;;
|
44
|
+
netbsd)
|
45
|
+
# see above about bsd 4.4
|
46
|
+
oper="$sys-$unamer"
|
47
|
+
arch="$unamem"
|
48
|
+
syst=""
|
49
|
+
chip="`sysctl -n hw.model`" # hopefully
|
50
|
+
kern=""
|
51
|
+
;;
|
52
|
+
linux)
|
53
|
+
# as in bsd 4.4, uname -v does not have useful info.
|
54
|
+
oper="$sys-$unamer"
|
55
|
+
syst=""
|
56
|
+
chip="$unamem"
|
57
|
+
kern=""
|
58
|
+
case "$chip" in
|
59
|
+
i386|i486|i586|i686)
|
60
|
+
arch="i386"
|
61
|
+
;;
|
62
|
+
alpha)
|
63
|
+
arch="alpha"
|
64
|
+
;;
|
65
|
+
esac
|
66
|
+
;;
|
67
|
+
aix)
|
68
|
+
# naturally IBM has to get uname -r and uname -v backwards. dorks.
|
69
|
+
oper="$sys-$unamev-$unamer"
|
70
|
+
arch="`arch | tr /: ..`"
|
71
|
+
syst=""
|
72
|
+
chip="$unamem"
|
73
|
+
kern=""
|
74
|
+
;;
|
75
|
+
sunos)
|
76
|
+
oper="$sys-$unamer-$unamev"
|
77
|
+
arch="`(uname -p || mach) | tr /: ..`"
|
78
|
+
syst="`arch | tr /: ..`"
|
79
|
+
chip="$unamem" # this is wrong; is there any way to get the real info?
|
80
|
+
kern="`arch -k | tr /: ..`"
|
81
|
+
;;
|
82
|
+
unix_sv)
|
83
|
+
oper="$sys-$unamer-$unamev"
|
84
|
+
arch="`uname -m`"
|
85
|
+
syst=""
|
86
|
+
chip="$unamem"
|
87
|
+
kern=""
|
88
|
+
;;
|
89
|
+
*)
|
90
|
+
oper="$sys-$unamer-$unamev"
|
91
|
+
arch="`arch | tr /: ..`"
|
92
|
+
syst=""
|
93
|
+
chip="$unamem"
|
94
|
+
kern=""
|
95
|
+
;;
|
96
|
+
esac
|
97
|
+
else
|
98
|
+
$CC -c trycpp.c
|
99
|
+
$LD -o trycpp trycpp.o
|
100
|
+
case `./trycpp` in
|
101
|
+
nextstep)
|
102
|
+
oper="nextstep-`hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p'`"
|
103
|
+
arch="`hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..`"
|
104
|
+
syst=""
|
105
|
+
chip="`hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...'`"
|
106
|
+
kern=""
|
107
|
+
;;
|
108
|
+
*)
|
109
|
+
oper="unknown"
|
110
|
+
arch=""
|
111
|
+
syst=""
|
112
|
+
chip=""
|
113
|
+
kern=""
|
114
|
+
;;
|
115
|
+
esac
|
116
|
+
rm -f trycpp.o trycpp
|
117
|
+
fi
|
118
|
+
|
119
|
+
case "$chip" in
|
120
|
+
80486)
|
121
|
+
# let's try to be consistent here. (BSD/OS)
|
122
|
+
chip=i486
|
123
|
+
;;
|
124
|
+
i486DX)
|
125
|
+
# respect the hyphen hierarchy. (FreeBSD)
|
126
|
+
chip=i486-dx
|
127
|
+
;;
|
128
|
+
i486.DX2)
|
129
|
+
# respect the hyphen hierarchy. (FreeBSD)
|
130
|
+
chip=i486-dx2
|
131
|
+
;;
|
132
|
+
Intel.586)
|
133
|
+
# no, you nitwits, there is no such chip. (NeXTStep)
|
134
|
+
chip=pentium
|
135
|
+
;;
|
136
|
+
i586)
|
137
|
+
# no, you nitwits, there is no such chip. (Linux)
|
138
|
+
chip=pentium
|
139
|
+
;;
|
140
|
+
i686)
|
141
|
+
# STOP SAYING THAT! (Linux)
|
142
|
+
chip=ppro
|
143
|
+
esac
|
144
|
+
|
145
|
+
if $CC -c x86cpuid.c
|
146
|
+
then
|
147
|
+
if $LD -o x86cpuid x86cpuid.o
|
148
|
+
then
|
149
|
+
x86cpuid="`./x86cpuid | tr /: ..`"
|
150
|
+
case "$x86cpuid" in
|
151
|
+
?*)
|
152
|
+
chip="$x86cpuid"
|
153
|
+
;;
|
154
|
+
esac
|
155
|
+
fi
|
156
|
+
fi
|
157
|
+
rm -f x86cpuid x86cpuid.o
|
158
|
+
|
159
|
+
echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]'
|
data/cdb-0.75/fmt.h
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#ifndef FMT_H
|
2
|
+
#define FMT_H
|
3
|
+
|
4
|
+
#define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */
|
5
|
+
#define FMT_LEN ((char *) 0) /* convenient abbreviation */
|
6
|
+
|
7
|
+
extern unsigned int fmt_uint(char *,unsigned int);
|
8
|
+
extern unsigned int fmt_uint0(char *,unsigned int,unsigned int);
|
9
|
+
extern unsigned int fmt_xint(char *,unsigned int);
|
10
|
+
extern unsigned int fmt_nbbint(char *,unsigned int,unsigned int,unsigned int,unsigned int);
|
11
|
+
extern unsigned int fmt_ushort(char *,unsigned short);
|
12
|
+
extern unsigned int fmt_xshort(char *,unsigned short);
|
13
|
+
extern unsigned int fmt_nbbshort(char *,unsigned int,unsigned int,unsigned int,unsigned short);
|
14
|
+
extern unsigned int fmt_ulong(char *,unsigned long);
|
15
|
+
extern unsigned int fmt_xlong(char *,unsigned long);
|
16
|
+
extern unsigned int fmt_nbblong(char *,unsigned int,unsigned int,unsigned int,unsigned long);
|
17
|
+
|
18
|
+
extern unsigned int fmt_plusminus(char *,int);
|
19
|
+
extern unsigned int fmt_minus(char *,int);
|
20
|
+
extern unsigned int fmt_0x(char *,int);
|
21
|
+
|
22
|
+
extern unsigned int fmt_str(char *,char *);
|
23
|
+
extern unsigned int fmt_strn(char *,char *,unsigned int);
|
24
|
+
|
25
|
+
#endif
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#include "fmt.h"
|
2
|
+
|
3
|
+
unsigned int fmt_ulong(register char *s,register unsigned long u)
|
4
|
+
{
|
5
|
+
register unsigned int len; register unsigned long q;
|
6
|
+
len = 1; q = u;
|
7
|
+
while (q > 9) { ++len; q /= 10; }
|
8
|
+
if (s) {
|
9
|
+
s += len;
|
10
|
+
do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
|
11
|
+
}
|
12
|
+
return len;
|
13
|
+
}
|
data/cdb-0.75/hier.c
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#include "auto_home.h"
|
2
|
+
|
3
|
+
void hier()
|
4
|
+
{
|
5
|
+
h(auto_home,-1,-1,02755);
|
6
|
+
d(auto_home,"bin",-1,-1,02755);
|
7
|
+
|
8
|
+
c(auto_home,"bin","cdbget",-1,-1,0755);
|
9
|
+
c(auto_home,"bin","cdbmake",-1,-1,0755);
|
10
|
+
c(auto_home,"bin","cdbdump",-1,-1,0755);
|
11
|
+
c(auto_home,"bin","cdbstats",-1,-1,0755);
|
12
|
+
c(auto_home,"bin","cdbtest",-1,-1,0755);
|
13
|
+
c(auto_home,"bin","cdbmake-12",-1,-1,0755);
|
14
|
+
c(auto_home,"bin","cdbmake-sv",-1,-1,0755);
|
15
|
+
}
|
data/cdb-0.75/install.c
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
#include "buffer.h"
|
2
|
+
#include "strerr.h"
|
3
|
+
#include "error.h"
|
4
|
+
#include "open.h"
|
5
|
+
#include "readwrite.h"
|
6
|
+
#include "exit.h"
|
7
|
+
|
8
|
+
extern void hier();
|
9
|
+
|
10
|
+
#define FATAL "install: fatal: "
|
11
|
+
|
12
|
+
int fdsourcedir = -1;
|
13
|
+
|
14
|
+
void h(home,uid,gid,mode)
|
15
|
+
char *home;
|
16
|
+
int uid;
|
17
|
+
int gid;
|
18
|
+
int mode;
|
19
|
+
{
|
20
|
+
if (mkdir(home,0700) == -1)
|
21
|
+
if (errno != error_exist)
|
22
|
+
strerr_die4sys(111,FATAL,"unable to mkdir ",home,": ");
|
23
|
+
if (chown(home,uid,gid) == -1)
|
24
|
+
strerr_die4sys(111,FATAL,"unable to chown ",home,": ");
|
25
|
+
if (chmod(home,mode) == -1)
|
26
|
+
strerr_die4sys(111,FATAL,"unable to chmod ",home,": ");
|
27
|
+
}
|
28
|
+
|
29
|
+
void d(home,subdir,uid,gid,mode)
|
30
|
+
char *home;
|
31
|
+
char *subdir;
|
32
|
+
int uid;
|
33
|
+
int gid;
|
34
|
+
int mode;
|
35
|
+
{
|
36
|
+
if (chdir(home) == -1)
|
37
|
+
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
|
38
|
+
if (mkdir(subdir,0700) == -1)
|
39
|
+
if (errno != error_exist)
|
40
|
+
strerr_die6sys(111,FATAL,"unable to mkdir ",home,"/",subdir,": ");
|
41
|
+
if (chown(subdir,uid,gid) == -1)
|
42
|
+
strerr_die6sys(111,FATAL,"unable to chown ",home,"/",subdir,": ");
|
43
|
+
if (chmod(subdir,mode) == -1)
|
44
|
+
strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",subdir,": ");
|
45
|
+
}
|
46
|
+
|
47
|
+
char inbuf[BUFFER_INSIZE];
|
48
|
+
char outbuf[BUFFER_OUTSIZE];
|
49
|
+
buffer ssin;
|
50
|
+
buffer ssout;
|
51
|
+
|
52
|
+
void c(home,subdir,file,uid,gid,mode)
|
53
|
+
char *home;
|
54
|
+
char *subdir;
|
55
|
+
char *file;
|
56
|
+
int uid;
|
57
|
+
int gid;
|
58
|
+
int mode;
|
59
|
+
{
|
60
|
+
int fdin;
|
61
|
+
int fdout;
|
62
|
+
|
63
|
+
if (fchdir(fdsourcedir) == -1)
|
64
|
+
strerr_die2sys(111,FATAL,"unable to switch back to source directory: ");
|
65
|
+
|
66
|
+
fdin = open_read(file);
|
67
|
+
if (fdin == -1)
|
68
|
+
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
|
69
|
+
buffer_init(&ssin,read,fdin,inbuf,sizeof inbuf);
|
70
|
+
|
71
|
+
if (chdir(home) == -1)
|
72
|
+
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
|
73
|
+
if (chdir(subdir) == -1)
|
74
|
+
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
|
75
|
+
|
76
|
+
fdout = open_trunc(file);
|
77
|
+
if (fdout == -1)
|
78
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
79
|
+
buffer_init(&ssout,write,fdout,outbuf,sizeof outbuf);
|
80
|
+
|
81
|
+
switch(buffer_copy(&ssout,&ssin)) {
|
82
|
+
case -2:
|
83
|
+
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
|
84
|
+
case -3:
|
85
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
86
|
+
}
|
87
|
+
|
88
|
+
close(fdin);
|
89
|
+
if (buffer_flush(&ssout) == -1)
|
90
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
91
|
+
if (fsync(fdout) == -1)
|
92
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
93
|
+
if (close(fdout) == -1) /* NFS silliness */
|
94
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
95
|
+
|
96
|
+
if (chown(file,uid,gid) == -1)
|
97
|
+
strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": ");
|
98
|
+
if (chmod(file,mode) == -1)
|
99
|
+
strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
|
100
|
+
}
|
101
|
+
|
102
|
+
void z(home,subdir,file,len,uid,gid,mode)
|
103
|
+
char *home;
|
104
|
+
char *subdir;
|
105
|
+
char *file;
|
106
|
+
int len;
|
107
|
+
int uid;
|
108
|
+
int gid;
|
109
|
+
int mode;
|
110
|
+
{
|
111
|
+
int fdout;
|
112
|
+
|
113
|
+
if (chdir(home) == -1)
|
114
|
+
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
|
115
|
+
if (chdir(subdir) == -1)
|
116
|
+
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
|
117
|
+
|
118
|
+
fdout = open_trunc(file);
|
119
|
+
if (fdout == -1)
|
120
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
121
|
+
buffer_init(&ssout,write,fdout,outbuf,sizeof outbuf);
|
122
|
+
|
123
|
+
while (len-- > 0)
|
124
|
+
if (buffer_put(&ssout,"",1) == -1)
|
125
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
126
|
+
|
127
|
+
if (buffer_flush(&ssout) == -1)
|
128
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
129
|
+
if (fsync(fdout) == -1)
|
130
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
131
|
+
if (close(fdout) == -1) /* NFS silliness */
|
132
|
+
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
|
133
|
+
|
134
|
+
if (chown(file,uid,gid) == -1)
|
135
|
+
strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": ");
|
136
|
+
if (chmod(file,mode) == -1)
|
137
|
+
strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
|
138
|
+
}
|
139
|
+
|
140
|
+
main()
|
141
|
+
{
|
142
|
+
fdsourcedir = open_read(".");
|
143
|
+
if (fdsourcedir == -1)
|
144
|
+
strerr_die2sys(111,FATAL,"unable to open current directory: ");
|
145
|
+
|
146
|
+
umask(077);
|
147
|
+
hier();
|
148
|
+
_exit(0);
|
149
|
+
}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#include <sys/types.h>
|
2
|
+
#include <sys/stat.h>
|
3
|
+
#include "strerr.h"
|
4
|
+
#include "error.h"
|
5
|
+
#include "readwrite.h"
|
6
|
+
#include "exit.h"
|
7
|
+
|
8
|
+
extern void hier();
|
9
|
+
|
10
|
+
#define FATAL "instcheck: fatal: "
|
11
|
+
#define WARNING "instcheck: warning: "
|
12
|
+
|
13
|
+
void perm(prefix1,prefix2,prefix3,file,type,uid,gid,mode)
|
14
|
+
char *prefix1;
|
15
|
+
char *prefix2;
|
16
|
+
char *prefix3;
|
17
|
+
char *file;
|
18
|
+
int type;
|
19
|
+
int uid;
|
20
|
+
int gid;
|
21
|
+
int mode;
|
22
|
+
{
|
23
|
+
struct stat st;
|
24
|
+
|
25
|
+
if (stat(file,&st) == -1) {
|
26
|
+
if (errno == error_noent)
|
27
|
+
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," does not exist",0);
|
28
|
+
else
|
29
|
+
strerr_warn4(WARNING,"unable to stat .../",file,": ",&strerr_sys);
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
33
|
+
if ((uid != -1) && (st.st_uid != uid))
|
34
|
+
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong owner",0);
|
35
|
+
if ((gid != -1) && (st.st_gid != gid))
|
36
|
+
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong group",0);
|
37
|
+
if ((st.st_mode & 07777) != mode)
|
38
|
+
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong permissions",0);
|
39
|
+
if ((st.st_mode & S_IFMT) != type)
|
40
|
+
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong type",0);
|
41
|
+
}
|
42
|
+
|
43
|
+
void h(home,uid,gid,mode)
|
44
|
+
char *home;
|
45
|
+
int uid;
|
46
|
+
int gid;
|
47
|
+
int mode;
|
48
|
+
{
|
49
|
+
perm("","","",home,S_IFDIR,uid,gid,mode);
|
50
|
+
}
|
51
|
+
|
52
|
+
void d(home,subdir,uid,gid,mode)
|
53
|
+
char *home;
|
54
|
+
char *subdir;
|
55
|
+
int uid;
|
56
|
+
int gid;
|
57
|
+
int mode;
|
58
|
+
{
|
59
|
+
if (chdir(home) == -1)
|
60
|
+
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
|
61
|
+
perm("",home,"/",subdir,S_IFDIR,uid,gid,mode);
|
62
|
+
}
|
63
|
+
|
64
|
+
void p(home,fifo,uid,gid,mode)
|
65
|
+
char *home;
|
66
|
+
char *fifo;
|
67
|
+
int uid;
|
68
|
+
int gid;
|
69
|
+
int mode;
|
70
|
+
{
|
71
|
+
if (chdir(home) == -1)
|
72
|
+
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
|
73
|
+
perm("",home,"/",fifo,S_IFIFO,uid,gid,mode);
|
74
|
+
}
|
75
|
+
|
76
|
+
void c(home,subdir,file,uid,gid,mode)
|
77
|
+
char *home;
|
78
|
+
char *subdir;
|
79
|
+
char *file;
|
80
|
+
int uid;
|
81
|
+
int gid;
|
82
|
+
int mode;
|
83
|
+
{
|
84
|
+
if (chdir(home) == -1)
|
85
|
+
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
|
86
|
+
if (chdir(subdir) == -1)
|
87
|
+
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
|
88
|
+
perm(".../",subdir,"/",file,S_IFREG,uid,gid,mode);
|
89
|
+
}
|
90
|
+
|
91
|
+
void z(home,file,len,uid,gid,mode)
|
92
|
+
char *home;
|
93
|
+
char *file;
|
94
|
+
int len;
|
95
|
+
int uid;
|
96
|
+
int gid;
|
97
|
+
int mode;
|
98
|
+
{
|
99
|
+
if (chdir(home) == -1)
|
100
|
+
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
|
101
|
+
perm("",home,"/",file,S_IFREG,uid,gid,mode);
|
102
|
+
}
|
103
|
+
|
104
|
+
main()
|
105
|
+
{
|
106
|
+
hier();
|
107
|
+
_exit(0);
|
108
|
+
}
|