annotate dgl/rlgwebd-compat.patch @ 100:44e8aaa20d02 default tip

Fix the format of archive links.
author John "Elwin" Edwards
date Wed, 03 Aug 2022 20:49:38 -0400
parents 1bddd1839831
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
1 diff --git a/dgamelaunch.c b/dgamelaunch.c
87
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
2 index fc831a9..cb03355 100644
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
3 --- a/dgamelaunch.c
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
4 +++ b/dgamelaunch.c
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
5 @@ -1489,7 +1489,10 @@ int
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
6 changepw (int dowrite)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
7 {
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
8 char buf[DGL_PASSWDLEN+1];
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
9 + char salt[21];
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
10 int error = 2;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
11 + int i;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
12 + FILE *urandom;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
13
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
14 /* A precondition is that struct `me' exists because we can be not-yet-logged-in. */
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
15 if (!me) {
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
16 @@ -1553,8 +1556,28 @@ changepw (int dowrite)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
17 error = 1;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
18 }
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
19
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
20 + salt[0] = salt[2] = salt[19] = '$';
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
21 + salt[1] = '6';
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
22 + salt[20] = '\0';
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
23 + urandom = fopen("/dev/urandom", "r");
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
24 + for (i = 3; i < 19; i++) {
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
25 + /* This does waste four random bytes. */
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
26 + fread(salt + i, 1, 1, urandom);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
27 + salt[i] &= 0x3f;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
28 + if (salt[i] < 26)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
29 + salt[i] += 'a';
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
30 + else if (salt[i] < 52)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
31 + salt[i] = 'A' + salt[i] - 26;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
32 + else if (salt[i] < 62)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
33 + salt[i] = '0' + salt[i] - 52;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
34 + else if (salt[i] == 62)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
35 + salt[i] = '.';
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
36 + else
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
37 + salt[i] = '/';
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
38 + }
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
39 + fclose(urandom);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
40 free(me->password);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
41 - me->password = strdup (crypt (buf, buf));
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
42 + me->password = strdup (crypt (buf, salt));
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
43
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
44 if (dowrite)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
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
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
48 assert (me != NULL);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
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
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
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;
87
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
59 @@ -2870,6 +2899,8 @@ main (int argc, char** argv)
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
60 }
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
61 }
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
62
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
63 + umask(0002);
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
64 +
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
65 if (globalconfig.locale) {
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
66 setlocale(LC_CTYPE, globalconfig.locale);
1bddd1839831 Update the dgamelaunch patch to work with the most recent changes.
John "Elwin" Edwards
parents: 69
diff changeset
67 }
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
68 diff --git a/dgamelaunch.h b/dgamelaunch.h
69
c2127bc98694 Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents: 24
diff changeset
69 index e298adf..411c7c3 100644
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
70 --- a/dgamelaunch.h
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
71 +++ b/dgamelaunch.h
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
72 @@ -20,7 +20,7 @@
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
73 #define dglsign(x) (x < 0 ? -1 : (x > 0 ? 1 : 0))
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
74
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
75 #define DGL_PLAYERNAMELEN 30 /* max. length of player name */
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
76 -#define DGL_PASSWDLEN 20 /* max. length of passwords */
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
77 +#define DGL_PASSWDLEN 108 /* max. length of passwords */
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
78 #define DGL_MAILMSGLEN 80 /* max. length of mail message */
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
79
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
80 #define DGL_MAXWATCHCOLS 10
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
81 diff --git a/dgl-common.c b/dgl-common.c
69
c2127bc98694 Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents: 24
diff changeset
82 index 80560b5..94f7b69 100644
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
83 --- a/dgl-common.c
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
84 +++ b/dgl-common.c
69
c2127bc98694 Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents: 24
diff changeset
85 @@ -608,7 +608,7 @@ game_read_extra_info(struct dg_game *game, const char *extra_info_file)
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
86 struct dg_game **
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
87 populate_games (int xgame, int *l, struct dg_user *me)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
88 {
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
89 - int fd, len, n, pid;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
90 + int fd, len, n, pid, is_node;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
91 DIR *pdir;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
92 struct dirent *pdirent;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
93 struct stat pstat;
69
c2127bc98694 Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents: 24
diff changeset
94 @@ -646,13 +646,15 @@ populate_games (int xgame, int *l, struct dg_user *me)
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
95
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
96 if (!inprog) continue;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
97
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
98 + is_node = strchr(pdirent->d_name, ':') && !strncmp(strchr(pdirent->d_name, ':'), ":node:", 6);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
99 +
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
100 snprintf (fullname, 130, "%s%s", inprog, pdirent->d_name);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
101
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
102 fd = 0;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
103 /* O_RDWR here should be O_RDONLY, but we need to test for
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
104 * an exclusive lock */
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
105 fd = open (fullname, O_RDWR);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
106 - if (fd >= 0 && (fcntl (fd, F_SETLK, &fl) == -1))
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
107 + if (fd >= 0 && (is_node || (fcntl (fd, F_SETLK, &fl) == -1)))
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
108 {
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
109 char *ttrecdir = NULL;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
110 strncpy(playername, pdirent->d_name, DGL_PLAYERNAMELEN);
69
c2127bc98694 Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents: 24
diff changeset
111 @@ -666,6 +668,9 @@ populate_games (int xgame, int *l, struct dg_user *me)
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
112 graceful_exit(145);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
113 }
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
114 replacestr++;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
115 + if (is_node) {
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
116 + replacestr += 5;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
117 + }
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
118
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
119 ttrecdir = dgl_format_str(game, me, myconfig[game]->ttyrecdir, playername);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
120 if (!ttrecdir) continue;
69
c2127bc98694 Update the dgamelaunch compatibility patch.
John "Elwin" Edwards
parents: 24
diff changeset
121 @@ -688,6 +693,8 @@ populate_games (int xgame, int *l, struct dg_user *me)
24
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
122 strlcpy (games[len]->name, pdirent->d_name,
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
123 strlen (pdirent->d_name) + 1);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
124
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
125 + if (is_node)
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
126 + replacestr += 5;
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
127 games[len]->date = malloc (11);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
128 strlcpy (games[len]->date, replacestr + 1, 11);
ce26225f7d9d Switch to the Git version of dgamelaunch.
John "Elwin" Edwards
parents:
diff changeset
129