(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:
Ron Koenderink 2007-03-10 16:29:51 +00:00
parent 32d62797d2
commit c97d79c0ee
6 changed files with 32 additions and 12 deletions

View file

@ -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;
}

View file

@ -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);