Mon, 23 Nov 2020 01:41:50 -0600
Delete a bunch of unused zephyr stuff
* Remove unused `ZSetFD`.
* Remove `__HM_set` which is never read.
* Remove `__Zephyr_open` global, which is redundant with `__Zephyr_fd != -1`.
* Remove `ZSetSrv.c`, as `ZSetServerState` is never called.
Consequently, remove `__Zephyr_server` global and all things that check it as it will never be TRUE.
* Remove zephyr internal debug code, as `ZSetDebug` is never called.
Also, make a couple debug messages go to libpurple.
* Remove unused `ZNewLocateUser` compatibility macro.
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/249/
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZInitialize function. | |
| 3 | * | |
| 4 | * Created by: Robert French | |
| 5 | * | |
| 6 | * Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology. | |
| 7 | * For copying and distribution information, see the file | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
8 | * "mit-copyright.h". |
| 2086 | 9 | */ |
| 10 | ||
| 10867 | 11 | #ifdef ZEPHYR_USES_KERBEROS |
| 12 | #ifdef WIN32 | |
| 13 | ||
| 14 | #else | |
| 15 | #include <krb_err.h> | |
| 16 | #endif | |
| 17 | #endif | |
| 18 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
2419
diff
changeset
|
19 | #include "internal.h" |
| 2086 | 20 | |
| 10867 | 21 | #ifdef WIN32 |
| 22 | #include <winsock2.h> | |
| 23 | #else | |
| 2086 | 24 | #include <sys/socket.h> |
| 25 | #endif | |
| 26 | ||
| 10867 | 27 | |
| 2419 | 28 | #ifndef INADDR_NONE |
| 29 | #define INADDR_NONE 0xffffffff | |
| 30 | #endif | |
| 31 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40165
diff
changeset
|
32 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40165
diff
changeset
|
33 | ZInitialize(void) |
| 2086 | 34 | { |
| 35 | struct servent *hmserv; | |
| 2419 | 36 | struct hostent *hostent; |
| 37 | char addr[4], hostname[MAXHOSTNAMELEN]; | |
| 38 | struct in_addr servaddr; | |
| 39 | struct sockaddr_in sin; | |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11105
diff
changeset
|
40 | int s; |
|
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11105
diff
changeset
|
41 | socklen_t sinsize = sizeof(sin); |
| 2419 | 42 | Code_t code; |
| 43 | ZNotice_t notice; | |
| 2086 | 44 | #ifdef ZEPHYR_USES_KERBEROS |
| 2419 | 45 | char *krealm = NULL; |
| 2086 | 46 | int krbval; |
| 2419 | 47 | char d1[ANAME_SZ], d2[INST_SZ]; |
| 2086 | 48 | #endif |
| 49 | ||
| 50 | (void) memset((char *)&__HM_addr, 0, sizeof(__HM_addr)); | |
| 51 | ||
| 52 | __HM_addr.sin_family = AF_INET; | |
| 53 | ||
| 54 | /* Set up local loopback address for HostManager */ | |
| 55 | addr[0] = 127; | |
| 56 | addr[1] = 0; | |
| 57 | addr[2] = 0; | |
| 58 | addr[3] = 1; | |
| 59 | ||
| 60 | hmserv = (struct servent *)getservbyname(HM_SVCNAME, "udp"); | |
| 61 | __HM_addr.sin_port = (hmserv) ? hmserv->s_port : HM_SVC_FALLBACK; | |
| 62 | ||
| 63 | (void) memcpy((char *)&__HM_addr.sin_addr, addr, 4); | |
| 64 | ||
| 2419 | 65 | /* Initialize the input queue */ |
| 66 | __Q_Tail = NULL; | |
| 67 | __Q_Head = NULL; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
68 | |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
69 | /* If there is no zhm, the code will fall back to something which might |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
70 | * not be "right", but this is is ok, since none of the servers call |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
71 | * krb_rd_req. */ |
| 2419 | 72 | |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
73 | servaddr.s_addr = INADDR_NONE; |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
74 | if ((code = ZOpenPort(NULL)) != ZERR_NONE) { |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
75 | return code; |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
76 | } |
| 2419 | 77 | |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
78 | if ((code = ZhmStat(NULL, ¬ice)) != ZERR_NONE) { |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
79 | return code; |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
80 | } |
| 2419 | 81 | |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
82 | ZClosePort(); |
| 2419 | 83 | |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
84 | /* the first field, which is NUL-terminated, is the server name. |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
85 | If this code ever support a multiplexing zhm, this will have to |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
86 | be made smarter, and probably per-message */ |
| 2419 | 87 | |
| 2086 | 88 | #ifdef ZEPHYR_USES_KERBEROS |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
89 | krealm = krb_realmofhost(notice.z_message); |
| 2419 | 90 | #endif |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
91 | hostent = gethostbyname(notice.z_message); |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
92 | if (hostent && hostent->h_addrtype == AF_INET) { |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
93 | memcpy(&servaddr, hostent->h_addr, sizeof(servaddr)); |
|
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
94 | } |
| 2419 | 95 | |
|
40624
6f7bbd42d36c
Delete a bunch of unused zephyr stuff
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
96 | ZFreeNotice(¬ice); |
| 2419 | 97 | |
| 98 | #ifdef ZEPHYR_USES_KERBEROS | |
| 99 | if (krealm) { | |
|
31955
384153346831
Fix up Zephyr g_strlcpy patch
Ethan Blanton <elb@pidgin.im>
parents:
31954
diff
changeset
|
100 | g_strlcpy(__Zephyr_realm, krealm, REALM_SZ); |
| 2419 | 101 | } else if ((krb_get_tf_fullname(TKT_FILE, d1, d2, __Zephyr_realm) |
| 102 | != KSUCCESS) && | |
| 103 | ((krbval = krb_get_lrealm(__Zephyr_realm, 1)) != KSUCCESS)) { | |
| 2086 | 104 | return (krbval); |
| 2419 | 105 | } |
| 106 | #else | |
|
32016
b1662f03fa07
Fix some un-fixes in the Zephyr strlcpy changes
Ethan Blanton <elb@pidgin.im>
parents:
31955
diff
changeset
|
107 | g_strlcpy(__Zephyr_realm, "local-realm", REALM_SZ); |
| 2086 | 108 | #endif |
| 109 | ||
| 2419 | 110 | __My_addr.s_addr = INADDR_NONE; |
| 111 | if (servaddr.s_addr != INADDR_NONE) { | |
| 112 | /* Try to get the local interface address by connecting a UDP | |
| 113 | * socket to the server address and getting the local address. | |
| 114 | * Some broken operating systems (e.g. Solaris 2.0-2.5) yield | |
| 115 | * INADDR_ANY (zero), so we have to check for that. */ | |
| 116 | s = socket(AF_INET, SOCK_DGRAM, 0); | |
| 117 | if (s != -1) { | |
| 118 | memset(&sin, 0, sizeof(sin)); | |
| 119 | sin.sin_family = AF_INET; | |
| 120 | memcpy(&sin.sin_addr, &servaddr, sizeof(servaddr)); | |
| 121 | sin.sin_port = HM_SRV_SVC_FALLBACK; | |
| 122 | if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) == 0 | |
| 123 | && getsockname(s, (struct sockaddr *) &sin, &sinsize) == 0 | |
| 124 | && sin.sin_addr.s_addr != 0) | |
| 125 | memcpy(&__My_addr, &sin.sin_addr, sizeof(__My_addr)); | |
| 126 | close(s); | |
| 127 | } | |
| 128 | } | |
| 129 | if (__My_addr.s_addr == INADDR_NONE) { | |
| 130 | /* We couldn't figure out the local interface address by the | |
| 131 | * above method. Try by resolving the local hostname. (This | |
| 132 | * is a pretty broken thing to do, and unfortunately what we | |
| 133 | * always do on server machines.) */ | |
| 134 | if (gethostname(hostname, sizeof(hostname)) == 0) { | |
| 135 | hostent = gethostbyname(hostname); | |
| 136 | if (hostent && hostent->h_addrtype == AF_INET) | |
| 137 | memcpy(&__My_addr, hostent->h_addr, sizeof(__My_addr)); | |
| 138 | } | |
| 139 | } | |
| 140 | /* If the above methods failed, zero out __My_addr so things will | |
| 141 | * sort of kind of work. */ | |
| 142 | if (__My_addr.s_addr == INADDR_NONE) | |
| 143 | __My_addr.s_addr = 0; | |
| 144 | ||
| 2086 | 145 | /* Get the sender so we can cache it */ |
| 146 | (void) ZGetSender(); | |
| 147 | ||
| 148 | return (ZERR_NONE); | |
| 149 | } | |
| 2419 | 150 |