standard defines instead of magic numbers to improve portability.
Also define WIN32 equivalents to the standard defines.
#define mkdir(dir,perm) _mkdir((dir))
#define random rand
#define srandom srand
-
+#define S_IRUSR _S_IREAD
+#define S_IWUSR _S_IWRITE
+#define S_IXUSR _S_IREAD
+#define S_IRGRP _S_IREAD
+#define S_IWGRP _S_IWRITE
+#define S_IXGRP _S_IREAD
+#define S_IROTH _S_IREAD
+#define S_IWOTH _S_IWRITE
+#define S_IXOTH _S_IREAD
+#define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR
+#define S_IRWXG S_IRGRP | S_IWGRP | S_IXGRP
+#define S_IRWXO S_IROTH | S_IWOTH | S_IXOTH
#endif /* _WIN32 */
+#ifndef S_IRWUG
+#define S_IRWUG S_IRGRP | S_IWGRP | S_IRUSR | S_IWUSR
+#endif
+
/* This is the structure we use to keep track of the global mobility
things, such as when the server is supposed to start/stop updating
mobility and the timestamp of when the game was last up. These
#if defined(_WIN32)
#include <io.h>
#endif
+#include <sys/stat.h>
#include "commands.h"
#include "land.h"
natp->nat_rejects[i] = 0;
natp->nat_newstim = 0;
natp->nat_annotim = 0;
- (void)creat(mailbox(buf, coun), 0660);
+ (void)creat(mailbox(buf, coun), S_IRWUG);
} else
pr("No special initializations done...\n");
#include <io.h>
#endif
#include <fcntl.h>
+#include <sys/stat.h>
#if !defined(_WIN32)
#include <unistd.h>
#endif
{
int fd;
- if ((fd = open(disablefil, O_RDWR | O_CREAT | O_TRUNC, 0660)) < 0)
+ if ((fd = open(disablefil, O_RDWR | O_CREAT | O_TRUNC, S_IRWUG)) < 0)
return RET_FAIL;
close(fd);
pr("Updates are disabled\n");
#include <share.h>
#endif
#include <fcntl.h>
+#include <sys/stat.h>
#include <signal.h>
#include <sys/types.h>
#if !defined(_WIN32)
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;
}
#include <unistd.h>
#endif
#include <fcntl.h>
+#include <sys/stat.h>
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
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);
#include <config.h>
#include <fcntl.h>
+#include <sys/stat.h>
#include <errno.h>
#if defined(_WIN32)
#include <direct.h>
#include <io.h>
#include "../lib/gen/getopt.h"
#else
-#include <sys/stat.h>
#include <unistd.h>
#endif
ef_init();
- if (mkdir(gamedir, 0770) < 0 && errno != EEXIST) {
+ if (mkdir(gamedir, S_IRWXU | S_IRWXG) < 0 && errno != EEXIST) {
perror(gamedir);
printf("Can't make game directory\n");
exit(1);
putrealm(&realm);
}
}
- if (mkdir(teldir, 0770) < 0 && errno != EEXIST) {
+ if (mkdir(teldir, S_IRWXU | S_IRWXG) < 0 && errno != EEXIST) {
perror(teldir);
printf("Can't make telegram directory\n");
exit(1);
}
for (x = MAXNOC - 1; x >= 0; x--) {
filename = mailbox(buf, x);
- close(creat(filename, 0660));
+ close(creat(filename, S_IRWUG));
}
- close(creat(timestampfil, 0660));
- close(creat(annfil, 0660));
+ close(creat(timestampfil, S_IRWUG));
+ close(creat(annfil, S_IRWUG));
/* create a zero-filled sector file */
memset(&sct, 0, sizeof(sct));