Use write results and fix queue/dbm/trustee warning leftovers
This commit is contained in:
26
src/nwdbm.c
26
src/nwdbm.c
@@ -2001,7 +2001,7 @@ static uint8 *test_add_dir(uint8 *unixname, uint8 *pp, int flags,
|
||||
else {
|
||||
chmod(unixname, permiss);
|
||||
if (uid >-1 && gid > -1)
|
||||
(void)chown(unixname, uid, gid);
|
||||
if (chown(unixname, uid, gid)) {}
|
||||
XDPRINTF((1, 0, "Created dir '%s'", unixname));
|
||||
}
|
||||
} else {
|
||||
@@ -2018,7 +2018,7 @@ static uint8 *test_add_dir(uint8 *unixname, uint8 *pp, int flags,
|
||||
if (flags&2) {
|
||||
chmod(unixname, permiss);
|
||||
if (uid >-1 && gid > -1)
|
||||
(void)chown(unixname, uid, gid);
|
||||
if (chown(unixname, uid, gid)) {}
|
||||
}
|
||||
}
|
||||
if (flags&1) {
|
||||
@@ -2060,7 +2060,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid)
|
||||
|
||||
(void)mkdir(fndir, mask);
|
||||
(void)chmod(fndir, mask);
|
||||
(void)chown(fndir, uid, gid);
|
||||
if (chown(fndir, uid, gid)) {}
|
||||
|
||||
if ((f=opendir(fndir)) != (DIR*)NULL) {
|
||||
struct dirent* dirbuff;
|
||||
@@ -2075,7 +2075,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid)
|
||||
if (f) {
|
||||
fprintf(f, "REM auto created by mars_nwe\r\n");
|
||||
fclose(f);
|
||||
(void)chown(fndir, uid, gid);
|
||||
if (chown(fndir, uid, gid)) {}
|
||||
chmod(fndir, 0600);
|
||||
}
|
||||
}
|
||||
@@ -2091,7 +2091,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid)
|
||||
&& !S_ISLNK(lstatb.st_mode) &&
|
||||
lstatb.st_uid != 0 && lstatb.st_gid != 0
|
||||
&& lstatb.st_uid != uid) {
|
||||
(void)chown(fndir, uid, gid);
|
||||
if (chown(fndir, uid, gid)) {}
|
||||
if (sys_has_trustee) {
|
||||
chmod(fndir, S_ISDIR(lstatb.st_mode) ? 700 : 600);
|
||||
}
|
||||
@@ -2108,7 +2108,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid)
|
||||
else
|
||||
downstr(p1+5);
|
||||
unlink(fndir);
|
||||
(void)symlink(buf1, fndir);
|
||||
if (symlink(buf1, fndir)) {}
|
||||
}
|
||||
|
||||
void test_ins_unx_user(uint32 id)
|
||||
@@ -3050,7 +3050,7 @@ static void bcreate_obj(uint32 id, char *name, int type,
|
||||
|
||||
/* 1/mstover -> ../id/1/2/3/4 */
|
||||
slprintf(buf1,sizeof(buf1)-1, "../id/%s", id_buf);
|
||||
(void)symlink(buf1, buf);
|
||||
if (symlink(buf1, buf)) {}
|
||||
|
||||
/* id/1/2/3/4 creat */
|
||||
len = slprintf(buf, sizeof(buf)-2,"%s/id/%s", path_bindery, id_buf);
|
||||
@@ -3063,17 +3063,17 @@ static void bcreate_obj(uint32 id, char *name, int type,
|
||||
strmaxcpy(buf+len, "name.o", sizeof(buf)-1-len);
|
||||
strmaxcpy(buf1, name, sizeof(buf1)-1);
|
||||
downstr(buf1);
|
||||
(void)symlink(buf1, buf);
|
||||
if (symlink(buf1, buf)) {}
|
||||
|
||||
/* typ -> 1 */
|
||||
strmaxcpy(buf+len, "typ.o", sizeof(buf)-1-len);
|
||||
slprintf(buf1, sizeof(buf1)-1,"%x", type);
|
||||
(void)symlink(buf1, buf);
|
||||
if (symlink(buf1, buf)) {}
|
||||
|
||||
/* flags & security */
|
||||
strmaxcpy(buf+len, "f+s.o", sizeof(buf)-1-len);
|
||||
slprintf(buf1, sizeof(buf1)-1,"%02x%02x", flags&0xff, security&0xff);
|
||||
(void)symlink(buf1, buf);
|
||||
if (symlink(buf1, buf)) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -3118,7 +3118,7 @@ static void bcreate_prop(uint32 id, int prop_id, char *name,
|
||||
/* id.p -> name */
|
||||
slprintf(buf1,sizeof(buf1)-1, "%s", name);
|
||||
downstr(buf1);
|
||||
(void)symlink(buf1, buf);
|
||||
if (symlink(buf1, buf)) {}
|
||||
|
||||
|
||||
/* x/name creat */
|
||||
@@ -3132,7 +3132,7 @@ static void bcreate_prop(uint32 id, int prop_id, char *name,
|
||||
/* flags & security */
|
||||
strmaxcpy(buf+len, "f+s", sizeof(buf)-1-len);
|
||||
slprintf(buf1, sizeof(buf1)-1,"%02x%02x", propflags&0xff, propsecurity&0xff);
|
||||
(void)symlink(buf1, buf);
|
||||
if (symlink(buf1, buf)) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -3181,7 +3181,7 @@ static void bcreate_val(uint32 id, int prop_id, int segment,
|
||||
sprintf(p1, "%02x", (int) *p++);
|
||||
p1+=2;
|
||||
}
|
||||
(void)symlink(buf1, buf);
|
||||
if (symlink(buf1, buf)) {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -313,14 +313,14 @@ static time_t get_time_field(uint8 *timef)
|
||||
static void build_queue_file_name(uint8 *job_file_name, INT_QUEUE_JOB *jo)
|
||||
{
|
||||
*job_file_name = (uint8) sprintf((char*)job_file_name+1,
|
||||
"%08lX.%03d", jo->file_entry_time, jo->job_id);
|
||||
"%08X.%03d", (unsigned int)jo->file_entry_time, jo->job_id);
|
||||
}
|
||||
|
||||
static void build_unix_queue_file(uint8 *buf, NWE_QUEUE *q, INT_QUEUE_JOB *jo)
|
||||
{
|
||||
if (q->queuedir_len) {
|
||||
memcpy(buf, q->queuedir, q->queuedir_len);
|
||||
sprintf(buf+q->queuedir_len, "/%08lX.%03d", jo->file_entry_time, jo->job_id);
|
||||
sprintf((char*)buf+q->queuedir_len, "/%08X.%03d", (unsigned int)jo->file_entry_time, jo->job_id);
|
||||
if (q->queuedir_downshift)
|
||||
downstr(buf+q->queuedir_len+1);
|
||||
} else *buf='\0';
|
||||
@@ -485,7 +485,7 @@ int nw_close_queue_job(uint32 q_id, int job_id,
|
||||
} else
|
||||
result=-0xff;
|
||||
}
|
||||
XDPRINTF(((result<0) ? 1 : 5, 0, "nw_close_queue_job, q=%lx, job=%d, result=%d",
|
||||
XDPRINTF(((result<0) ? 1 : 5, 0, "nw_close_queue_job, q=%x, job=%d, result=%d",
|
||||
q_id, job_id, result));
|
||||
return(result);
|
||||
}
|
||||
@@ -915,7 +915,7 @@ int nw_creat_queue(int q_typ, uint8 *q_name, int q_name_len,
|
||||
path_len=10;
|
||||
path=q_directory+path_len;
|
||||
}
|
||||
sprintf(path, "/%08lX.QDR", obj.id);
|
||||
sprintf(path, "/%08X.QDR", obj.id);
|
||||
*q_id = obj.id;
|
||||
nw_new_obj_prop(obj.id, NULL, 0, 0, 0,
|
||||
"Q_DIRECTORY", P_FL_ITEM, 0x31,
|
||||
|
||||
@@ -398,10 +398,10 @@ static int del_trustee_from_disk(int volume, dev_t dev, ino_t inode, uint32 id)
|
||||
(int) buf_uc[2],
|
||||
(int) buf_uc[3],
|
||||
(unsigned int)id);
|
||||
(void)seteuid(0);
|
||||
if (seteuid(0)) {}
|
||||
if (!unlink(buf))
|
||||
result=0;
|
||||
(void)reseteuid();
|
||||
if (reseteuid()) {}
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -423,12 +423,12 @@ unsigned int tru_vol_sernum(int volume, int mode)
|
||||
}
|
||||
if (mode) {
|
||||
if (++sernum==MAX_U32) sernum=1;
|
||||
(void)seteuid(0);
|
||||
if (seteuid(0)) {}
|
||||
unlink(buf);
|
||||
slprintf(buf1, sizeof(buf1)-1, "%x", sernum);
|
||||
if (symlink(buf1, buf))
|
||||
errorp(0, "rw_trustee_sernum", "symlink %s %s failed", buf1, buf);
|
||||
(void)reseteuid();
|
||||
if (reseteuid()) {}
|
||||
tru_free_cache(volume);
|
||||
}
|
||||
return(sernum);
|
||||
@@ -449,12 +449,12 @@ void tru_free_file_trustees_from_disk(int volume, int dev, ino_t inode)
|
||||
(int) buf_uc[1],
|
||||
(int) buf_uc[2]);
|
||||
slprintf(buf+len, sizeof(buf) - len -1, "t.%x", (int)buf_uc[3]);
|
||||
(void)seteuid(0);
|
||||
if (seteuid(0)) {}
|
||||
unx_xrmdir(buf);
|
||||
/* now we remove the name of the dir/file */
|
||||
slprintf(buf+len, sizeof(buf) -len -1, "n.%x", (int)buf_uc[3]);
|
||||
unlink(buf);
|
||||
(void)reseteuid();
|
||||
if (reseteuid()) {}
|
||||
}
|
||||
|
||||
int tru_del_trustee(int volume, uint8 *unixname, struct stat *stb, uint32 id)
|
||||
@@ -601,7 +601,7 @@ static int local_tru_add_trustee_set(int volume, uint8 *unixname,
|
||||
int volumenamelen = get_volume_unixnamlen(volume);
|
||||
uint8 ufnbuf[2];
|
||||
uint8 *ufn;
|
||||
(void)seteuid(0);
|
||||
if (seteuid(0)) {}
|
||||
while (count--) {
|
||||
if (! ((own_eff_rights & TRUSTEE_S) || (act_id_flags&1)) ) {
|
||||
/* only user with TRUSTEE_S are allowed to set TRUSTEE_S */
|
||||
@@ -614,7 +614,7 @@ static int local_tru_add_trustee_set(int volume, uint8 *unixname,
|
||||
nwoic->id, nwoic->trustee, volume, unixname, -result);
|
||||
})
|
||||
if (result){
|
||||
(void)reseteuid();
|
||||
if (reseteuid()) {}
|
||||
goto func_err;
|
||||
}
|
||||
nwoic++;
|
||||
@@ -626,7 +626,7 @@ static int local_tru_add_trustee_set(int volume, uint8 *unixname,
|
||||
*(ufn+1)='\0';
|
||||
}
|
||||
creat_trustee_path(volume, stb->st_dev, stb->st_ino, ufn);
|
||||
(void)reseteuid();
|
||||
if (reseteuid()) {}
|
||||
#if 0 /* now in tru_add_trustee_set */
|
||||
tru_vol_sernum(volume, 1); /* trustee sernum needs updated */
|
||||
#endif
|
||||
@@ -652,7 +652,7 @@ int tru_add_trustee_set(int volume, uint8 *unixname,
|
||||
char *p = unixname+len;
|
||||
char *volp = unixname+vollen;
|
||||
|
||||
(void)seteuid(0);
|
||||
if (seteuid(0)) {}
|
||||
while (--p > volp) {
|
||||
if (*p == '/') {
|
||||
struct stat statb;
|
||||
@@ -675,7 +675,7 @@ int tru_add_trustee_set(int volume, uint8 *unixname,
|
||||
*p='/';
|
||||
}
|
||||
}
|
||||
(void)reseteuid();
|
||||
if (reseteuid()) {}
|
||||
tru_vol_sernum(volume, 1); /* trustee sernum needs updated */
|
||||
}
|
||||
return (result);
|
||||
@@ -715,9 +715,9 @@ int tru_set_inherited_mask(int volume, uint8 *unixname,
|
||||
FILE_TRUSTEE_NODE *tr=find_trustee_node(volume, stb->st_dev, stb->st_ino);
|
||||
if (tr && (!(tr->mode_flags&0x1e) || !act_uid)) {
|
||||
int result;
|
||||
(void)seteuid(0);
|
||||
if (seteuid(0)) {}
|
||||
result=put_trustee_to_disk(volume, stb->st_dev, stb->st_ino, 0L, new_mask);
|
||||
(void)reseteuid();
|
||||
if (reseteuid()) {}
|
||||
if (!result)
|
||||
tru_vol_sernum(volume, 1); /* trustee sernum needs updated */
|
||||
return(result);
|
||||
|
||||
Reference in New Issue
Block a user