(add, disa, ef_open, logerror, main): Switch permissions to
standard defines instead of magic numbers to improve portability. Also define WIN32 equivalents to the standard defines.
This commit is contained in:
parent
32d62797d2
commit
c97d79c0ee
6 changed files with 32 additions and 12 deletions
|
@ -41,6 +41,7 @@
|
|||
#include <share.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(_WIN32)
|
||||
|
@ -90,12 +91,12 @@ ef_open(int type, int how)
|
|||
oflags |= O_BINARY;
|
||||
if ((fd = sopen(ep->file, oflags,
|
||||
how & EFF_RDONLY ? SH_DENYNO : SH_DENYWR,
|
||||
0660)) < 0) {
|
||||
S_IRWUG)) < 0) {
|
||||
logerror("Can't open %s (%s)", ep->file, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if ((fd = open(ep->file, oflags, 0660)) < 0) {
|
||||
if ((fd = open(ep->file, oflags, S_IRWUG)) < 0) {
|
||||
logerror("Can't open %s (%s)", ep->file, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
@ -93,7 +94,8 @@ logerror(char *format, ...)
|
|||
time(&now);
|
||||
memcpy(buf, ctime(&now), ctime_len);
|
||||
buf[ctime_len] = ' ';
|
||||
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0660)) < 0)
|
||||
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND,
|
||||
S_IRWUG)) < 0)
|
||||
return;
|
||||
write(logf, buf, strlen(buf));
|
||||
close(logf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue