116 lines
3.6 KiB
Diff
116 lines
3.6 KiB
Diff
diff --git a/dgamelaunch.c b/dgamelaunch.c
|
|
index fbf6ef5..b52b545 100644
|
|
--- a/dgamelaunch.c
|
|
+++ b/dgamelaunch.c
|
|
@@ -1489,7 +1489,10 @@ int
|
|
changepw (int dowrite)
|
|
{
|
|
char buf[DGL_PASSWDLEN+1];
|
|
+ char salt[21];
|
|
int error = 2;
|
|
+ int i;
|
|
+ FILE *urandom;
|
|
|
|
/* A precondition is that struct `me' exists because we can be not-yet-logged-in. */
|
|
if (!me) {
|
|
@@ -1553,8 +1556,28 @@ changepw (int dowrite)
|
|
error = 1;
|
|
}
|
|
|
|
+ salt[0] = salt[2] = salt[19] = '$';
|
|
+ salt[1] = '6';
|
|
+ salt[20] = '\0';
|
|
+ urandom = fopen("/dev/urandom", "r");
|
|
+ for (i = 3; i < 19; i++) {
|
|
+ /* This does waste four random bytes. */
|
|
+ fread(salt + i, 1, 1, urandom);
|
|
+ salt[i] &= 0x3f;
|
|
+ if (salt[i] < 26)
|
|
+ salt[i] += 'a';
|
|
+ else if (salt[i] < 52)
|
|
+ salt[i] = 'A' + salt[i] - 26;
|
|
+ else if (salt[i] < 62)
|
|
+ salt[i] = '0' + salt[i] - 52;
|
|
+ else if (salt[i] == 62)
|
|
+ salt[i] = '.';
|
|
+ else
|
|
+ salt[i] = '/';
|
|
+ }
|
|
+ fclose(urandom);
|
|
free(me->password);
|
|
- me->password = strdup (crypt (buf, buf));
|
|
+ me->password = strdup (crypt (buf, salt));
|
|
|
|
if (dowrite)
|
|
writefile (0);
|
|
@@ -2053,6 +2076,8 @@ passwordgood (char *cpw)
|
|
{
|
|
assert (me != NULL);
|
|
|
|
+ if (!strncmp (crypt (cpw, me->password), me->password, DGL_PASSWDLEN))
|
|
+ return 1;
|
|
if (!strncmp (crypt (cpw, cpw), me->password, DGL_PASSWDLEN))
|
|
return 1;
|
|
if (!strncmp (cpw, me->password, DGL_PASSWDLEN))
|
|
diff --git a/dgamelaunch.h b/dgamelaunch.h
|
|
index b9ce41c..ca5e11b 100644
|
|
--- a/dgamelaunch.h
|
|
+++ b/dgamelaunch.h
|
|
@@ -20,7 +20,7 @@
|
|
#define dglsign(x) (x < 0 ? -1 : (x > 0 ? 1 : 0))
|
|
|
|
#define DGL_PLAYERNAMELEN 30 /* max. length of player name */
|
|
-#define DGL_PASSWDLEN 20 /* max. length of passwords */
|
|
+#define DGL_PASSWDLEN 108 /* max. length of passwords */
|
|
#define DGL_MAILMSGLEN 80 /* max. length of mail message */
|
|
|
|
#define DGL_MAXWATCHCOLS 10
|
|
diff --git a/dgl-common.c b/dgl-common.c
|
|
index e5c80bc..fbc4eea 100644
|
|
--- a/dgl-common.c
|
|
+++ b/dgl-common.c
|
|
@@ -593,7 +593,7 @@ game_read_extra_info(struct dg_game *game, const char *extra_info_file)
|
|
struct dg_game **
|
|
populate_games (int xgame, int *l, struct dg_user *me)
|
|
{
|
|
- int fd, len, n, pid;
|
|
+ int fd, len, n, pid, is_node;
|
|
DIR *pdir;
|
|
struct dirent *pdirent;
|
|
struct stat pstat;
|
|
@@ -631,13 +631,15 @@ populate_games (int xgame, int *l, struct dg_user *me)
|
|
|
|
if (!inprog) continue;
|
|
|
|
+ is_node = strchr(pdirent->d_name, ':') && !strncmp(strchr(pdirent->d_name, ':'), ":node:", 6);
|
|
+
|
|
snprintf (fullname, 130, "%s%s", inprog, pdirent->d_name);
|
|
|
|
fd = 0;
|
|
/* O_RDWR here should be O_RDONLY, but we need to test for
|
|
* an exclusive lock */
|
|
fd = open (fullname, O_RDWR);
|
|
- if (fd >= 0 && (fcntl (fd, F_SETLK, &fl) == -1))
|
|
+ if (fd >= 0 && (is_node || (fcntl (fd, F_SETLK, &fl) == -1)))
|
|
{
|
|
char *ttrecdir = NULL;
|
|
strncpy(playername, pdirent->d_name, DGL_PLAYERNAMELEN);
|
|
@@ -651,6 +653,9 @@ populate_games (int xgame, int *l, struct dg_user *me)
|
|
graceful_exit(145);
|
|
}
|
|
replacestr++;
|
|
+ if (is_node) {
|
|
+ replacestr += 5;
|
|
+ }
|
|
|
|
ttrecdir = dgl_format_str(game, me, myconfig[game]->ttyrecdir, playername);
|
|
if (!ttrecdir) continue;
|
|
@@ -673,6 +678,8 @@ populate_games (int xgame, int *l, struct dg_user *me)
|
|
strlcpy (games[len]->name, pdirent->d_name,
|
|
strlen (pdirent->d_name) + 1);
|
|
|
|
+ if (is_node)
|
|
+ replacestr += 5;
|
|
games[len]->date = malloc (11);
|
|
strlcpy (games[len]->date, replacestr + 1, 11);
|
|
|