#define DFLTNAME "default"
struct userpath
*Mchdef
= NULL
, *Logdef
= NULL
;
* chkpth(logname, mchname, path)
* char *path, *logname, *mchname;
* chkpth - this routine will check the path table for the
* machine or log name (non-null parameter) to see if the
* starts with an acceptable prefix.
chkpth(logname
, mchname
, path
)
char *path
, *logname
, *mchname
;
if (prefix(THISDIR
, path
))
ASSERT(ret
== 0, "INIT USERFILE %d", Nbrusers
);
for (u
= Upt
, i
= 0; i
< Nbrusers
; i
++, u
++) {
if (*logname
!= '\0' && strcmp(logname
, u
->us_lname
) == SAME
)
if (*mchname
!= '\0' && strcmp(mchname
, u
->us_mname
) == SAME
)
/* check for /../ in path name */
for (s
= path
; *s
!= '\0'; s
++) {
if (*s
== '/' && prefix("../", (++s
)))
if (strcmp(*p
, "/") != SAME
) {
if (chklnk(path
) > LINKLEVEL
)
for (p
= u
->us_path
; *p
!= NULL
; p
++)
if (prefix(Spool
, path
)) {
if ((c
= *lastpart(path
)) == DATAPRE
/* path name not valid */
* rdpth - this routine will read the USFILE and
* construct the userpath structure pointed to by (u);
char buf
[BUFSIZ
+ 1], *pbuf
[BUFSIZ
+ 1], *pc
, **cp
;
extern char *calloc(), *index();
if ((uf
= fopen(USERFILE
, "r")) == NULL
) {
while (fgets(buf
, BUFSIZ
, uf
) != NULL
) {
if (++Nbrusers
> MAXUSERS
) {
if ((pc
= calloc(strlen(buf
) + 1, sizeof (char)))
/* can not allocate space */
nargs
= getargs(pc
, pbuf
);
pc
= index(u
->us_lname
, ',');
pc
= u
+ strlen(u
->us_lname
);
if (*u
->us_lname
== '\0')
else if (*u
->us_mname
== '\0')
if (strcmp(pbuf
[1], "c") == SAME
) {
calloc(nargs
- i
+ 1, sizeof (char *))) == NULL
) {
/* can not allocate space */
* callback(name) check for callback
ASSERT(ret
== 0, "INIT USERFILE %d", Nbrusers
);
for (u
= Upt
, i
= 0; i
< Nbrusers
; u
++, i
++) {
if (strcmp(u
->us_lname
, name
) != SAME
)
* chklnk(name) get number of links
* return codes: 0 - stat failed or directory | number of links
if (stat(name
, &s
) == -1)
if ((s
.st_mode
& S_IFMT
) == S_IFDIR
)
* chkperm(file, user, mopt) check write permission of file
* char *mopt; none NULL - create directories
* if mopt != NULL and permissions are ok,
* a side effect of this routine is to make
* directories up to the last part of the
* filename (if they do not exist).
chkperm(file
, user
, mopt
)
char *file
, *user
, *mopt
;
if (stat(file
, &s
) != -1)
if ((ret
= stat(dir
, &s
)) == -1
bits
= (geteuid() == 0) ? 02 : 0200;
if ((s
.st_mode
& bits
) == 0)