Fix ncpserv, nwfile and nwshare warning hot spots
This commit is contained in:
@@ -84,29 +84,29 @@ static void write_to_nwserv(int what, int connection, int mode,
|
||||
{
|
||||
switch (what) {
|
||||
case 0x2222 : /* insert wdog connection */
|
||||
write(FD_NWSERV, &what, sizeof(int));
|
||||
write(FD_NWSERV, &connection, sizeof(int));
|
||||
write(FD_NWSERV, &size, sizeof(int));
|
||||
write(FD_NWSERV, data, size); /* ipxAddr_t + socknr */
|
||||
(void)write(FD_NWSERV, &what, sizeof(int));
|
||||
(void)write(FD_NWSERV, &connection, sizeof(int));
|
||||
(void)write(FD_NWSERV, &size, sizeof(int));
|
||||
(void)write(FD_NWSERV, data, size); /* ipxAddr_t + socknr */
|
||||
break;
|
||||
|
||||
case 0x4444 : /* tell the wdog there's no need to look 0 */
|
||||
/* activate wdogs to free connection 1 */
|
||||
/* the connection ist closed 99 */
|
||||
write(FD_NWSERV, &what, sizeof(int));
|
||||
write(FD_NWSERV, &connection, sizeof(int));
|
||||
write(FD_NWSERV, &mode, sizeof(int));
|
||||
(void)write(FD_NWSERV, &what, sizeof(int));
|
||||
(void)write(FD_NWSERV, &connection, sizeof(int));
|
||||
(void)write(FD_NWSERV, &mode, sizeof(int));
|
||||
break;
|
||||
|
||||
case 0x5555 : /* close connection */
|
||||
case 0x6666 : /* send to client that server holds message */
|
||||
write(FD_NWSERV, &what, sizeof(int));
|
||||
write(FD_NWSERV, &connection, sizeof(int));
|
||||
(void)write(FD_NWSERV, &what, sizeof(int));
|
||||
(void)write(FD_NWSERV, &connection, sizeof(int));
|
||||
break;
|
||||
|
||||
case 0xffff : /* tell nwserv to down the server */
|
||||
write(FD_NWSERV, &what, sizeof(int));
|
||||
write(FD_NWSERV, &what, sizeof(int));
|
||||
(void)write(FD_NWSERV, &what, sizeof(int));
|
||||
(void)write(FD_NWSERV, &what, sizeof(int));
|
||||
break;
|
||||
|
||||
default : break;
|
||||
@@ -739,7 +739,7 @@ int main(int argc, char *argv[])
|
||||
return(1);
|
||||
}
|
||||
nwconn_state = shmat(nwconn_state_shm_id, NULL, SHM_R);
|
||||
if ((int )(nwconn_state) == -1) {
|
||||
if (nwconn_state == (char *)-1) {
|
||||
errorp(1, "Can't attach shared memory segment", NULL);
|
||||
return(1);
|
||||
}
|
||||
|
||||
48
src/nwfile.c
48
src/nwfile.c
@@ -152,9 +152,9 @@ static int free_file_handle(int fhandle)
|
||||
/* now set date and time */
|
||||
struct utimbuf ut;
|
||||
ut.actime = ut.modtime = fh->tmodi;
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
utime(fh->fname, &ut);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
fh->tmodi = 0L;
|
||||
}
|
||||
}
|
||||
@@ -209,9 +209,9 @@ static int open_with_root_access(char *path, int mode)
|
||||
{
|
||||
int fd = open(path, mode);
|
||||
if (fd < 0 && errno == EACCES) {
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
fd = open(path, mode);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
}
|
||||
return(fd);
|
||||
}
|
||||
@@ -299,9 +299,9 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
|
||||
|
||||
if (!exist) {
|
||||
/* we do it again as root to get always the correct information */
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
exist = stat(unixname, stbuff) ? 0 : 1;
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
}
|
||||
|
||||
#if 0 /* mst:04-Apr-00, not needed here */
|
||||
@@ -407,9 +407,9 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
|
||||
uint8 *p=(uint8*)strrchr(unixname, '/');
|
||||
if (NULL != p && ((p - unixname)+1) >= volnamlen ) { /* parent dir */
|
||||
*p='\0';
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
completition=stat(unixname, stbuff);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
if (!completition) {
|
||||
eff_rights = tru_get_eff_rights(volume, unixname, stbuff);
|
||||
dwattrib = get_nw_attrib_dword(volume, unixname, stbuff);
|
||||
@@ -474,9 +474,9 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
|
||||
fh->fd = open_with_root_access(fh->fname, acm);
|
||||
if (fh->fd != -1){
|
||||
if (acm&O_TRUNC) {
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
stat(fh->fname, stbuff);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
}
|
||||
} else
|
||||
completition=-0x9c;
|
||||
@@ -492,9 +492,9 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
|
||||
if (fh->fd==-1)
|
||||
completition=-0x9c;
|
||||
else {
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
stat(fh->fname, stbuff);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -672,9 +672,9 @@ int nw_close_file(int fhandle, int reset_reuse, int task)
|
||||
&& !(fh->fh_flags & FH_IS_READONLY)) {
|
||||
struct utimbuf ut;
|
||||
ut.actime = ut.modtime = fh->tmodi;
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
utime(fh->fname, &ut);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
fh->tmodi = 0L;
|
||||
}
|
||||
#ifdef TEST_FNAME
|
||||
@@ -715,9 +715,9 @@ int nw_commit_file(int fhandle)
|
||||
if (fh->tmodi > 0L) {
|
||||
struct utimbuf ut;
|
||||
ut.actime = ut.modtime = fh->tmodi;
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
utime(fh->fname, &ut);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
fh->tmodi = 0L;
|
||||
}
|
||||
fh->fd=dup2(fd, fh->fd);
|
||||
@@ -729,9 +729,9 @@ int nw_commit_file(int fhandle)
|
||||
if (fh->tmodi > 0L) {
|
||||
struct utimbuf ut;
|
||||
ut.actime = ut.modtime = fh->tmodi;
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
utime(fh->fname, &ut);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1268,9 +1268,9 @@ int nw_log_logical_record(int lock_flag,
|
||||
new_str(path_share_lock_files, buff);
|
||||
else
|
||||
new_str(path_share_lock_files, "/var/spool/nwserv/.locks");
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
unx_xmkdir(path_share_lock_files, 0755);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
}
|
||||
|
||||
sprintf(fullpath,"%s/%s.k", path_share_lock_files, fn);
|
||||
@@ -1282,9 +1282,9 @@ int nw_log_logical_record(int lock_flag,
|
||||
if (lock_flag < 0) /* unlock */
|
||||
return(-0xff);
|
||||
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
fd = open(fullpath, O_RDWR|O_CREAT, 0600);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
|
||||
if (fcntl(fd, F_SETLK, &flockd))
|
||||
/* already locked by other process */
|
||||
@@ -1340,9 +1340,9 @@ int nw_log_logical_record(int lock_flag,
|
||||
close(lf->fd);
|
||||
|
||||
#if 0 /* TODO remove file if it is not opened/locked by other process */
|
||||
seteuid(0);
|
||||
(void)seteuid(0);
|
||||
unlink(fullpath);
|
||||
reseteuid();
|
||||
(void)reseteuid();
|
||||
#endif
|
||||
|
||||
xfree(lf->fn);
|
||||
|
||||
@@ -193,10 +193,12 @@ int share_file(dev_t dev, ino_t inode, int open_mode, int action)
|
||||
new_str(path_share_lock_files, buff);
|
||||
else
|
||||
new_str(path_share_lock_files, "/var/spool/nwserv/.locks");
|
||||
seteuid(0);
|
||||
if (seteuid(0))
|
||||
return(-1);
|
||||
unx_xmkdir(path_share_lock_files, 0755);
|
||||
} else
|
||||
seteuid(0);
|
||||
if (seteuid(0))
|
||||
return(-1);
|
||||
l=sprintf(buff, "%s/%" PRIxMAX ".sm", path_share_lock_files,
|
||||
(uintmax_t)dev);
|
||||
sd->fd_sm = open(buff, O_RDWR|O_CREAT, 0600);
|
||||
|
||||
Reference in New Issue
Block a user