Mercurial > hg > rlgallery-misc
annotate dgl/rlgwebd-compat.patch @ 79:ea014ed97581
Add a script for making backups.
author | John "Elwin" Edwards |
---|---|
date | Fri, 13 Jan 2017 17:36:23 -0500 |
parents | c2127bc98694 |
children | 1bddd1839831 |
rev | line source |
---|---|
24 | 1 diff --git a/dgamelaunch.c b/dgamelaunch.c |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
2 index a52812d..6107851 100644 |
24 | 3 --- a/dgamelaunch.c |
4 +++ b/dgamelaunch.c | |
5 @@ -1489,7 +1489,10 @@ int | |
6 changepw (int dowrite) | |
7 { | |
8 char buf[DGL_PASSWDLEN+1]; | |
9 + char salt[21]; | |
10 int error = 2; | |
11 + int i; | |
12 + FILE *urandom; | |
13 | |
14 /* A precondition is that struct `me' exists because we can be not-yet-logged-in. */ | |
15 if (!me) { | |
16 @@ -1553,8 +1556,28 @@ changepw (int dowrite) | |
17 error = 1; | |
18 } | |
19 | |
20 + salt[0] = salt[2] = salt[19] = '$'; | |
21 + salt[1] = '6'; | |
22 + salt[20] = '\0'; | |
23 + urandom = fopen("/dev/urandom", "r"); | |
24 + for (i = 3; i < 19; i++) { | |
25 + /* This does waste four random bytes. */ | |
26 + fread(salt + i, 1, 1, urandom); | |
27 + salt[i] &= 0x3f; | |
28 + if (salt[i] < 26) | |
29 + salt[i] += 'a'; | |
30 + else if (salt[i] < 52) | |
31 + salt[i] = 'A' + salt[i] - 26; | |
32 + else if (salt[i] < 62) | |
33 + salt[i] = '0' + salt[i] - 52; | |
34 + else if (salt[i] == 62) | |
35 + salt[i] = '.'; | |
36 + else | |
37 + salt[i] = '/'; | |
38 + } | |
39 + fclose(urandom); | |
40 free(me->password); | |
41 - me->password = strdup (crypt (buf, buf)); | |
42 + me->password = strdup (crypt (buf, salt)); | |
43 | |
44 if (dowrite) | |
45 writefile (0); | |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
46 @@ -2054,6 +2077,12 @@ passwordgood (char *cpw) |
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
47 char *crypted; |
24 | 48 assert (me != NULL); |
49 | |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
50 + crypted = crypt (cpw, me->password); |
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
51 + if (crypted == NULL) |
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
52 + return 0; |
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
53 + if (!strncmp (crypted, me->password, DGL_PASSWDLEN)) |
24 | 54 + return 1; |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
55 + |
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
56 crypted = crypt (cpw, cpw); |
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
57 if (crypted == NULL) |
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
58 return 0; |
24 | 59 diff --git a/dgamelaunch.h b/dgamelaunch.h |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
60 index e298adf..411c7c3 100644 |
24 | 61 --- a/dgamelaunch.h |
62 +++ b/dgamelaunch.h | |
63 @@ -20,7 +20,7 @@ | |
64 #define dglsign(x) (x < 0 ? -1 : (x > 0 ? 1 : 0)) | |
65 | |
66 #define DGL_PLAYERNAMELEN 30 /* max. length of player name */ | |
67 -#define DGL_PASSWDLEN 20 /* max. length of passwords */ | |
68 +#define DGL_PASSWDLEN 108 /* max. length of passwords */ | |
69 #define DGL_MAILMSGLEN 80 /* max. length of mail message */ | |
70 | |
71 #define DGL_MAXWATCHCOLS 10 | |
72 diff --git a/dgl-common.c b/dgl-common.c | |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
73 index 80560b5..94f7b69 100644 |
24 | 74 --- a/dgl-common.c |
75 +++ b/dgl-common.c | |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
76 @@ -608,7 +608,7 @@ game_read_extra_info(struct dg_game *game, const char *extra_info_file) |
24 | 77 struct dg_game ** |
78 populate_games (int xgame, int *l, struct dg_user *me) | |
79 { | |
80 - int fd, len, n, pid; | |
81 + int fd, len, n, pid, is_node; | |
82 DIR *pdir; | |
83 struct dirent *pdirent; | |
84 struct stat pstat; | |
69
c2127bc98694
Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents:
24
diff
changeset
|
85 @@ -646,13 +646,15 @@ populate_games (int xgame, int *l, struct dg_user *me) |
24 | 86 |
87 if (!inprog) continue; | |
88 | |
89 + is_node = strchr(pdirent->d_name, ':') && !strncmp(strchr(pdirent->d_name, ':'), ":node:", 6); | |
90 + | |