summaryrefslogtreecommitdiff
path: root/openbsd-compat/port-aix.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-02-06 16:17:51 +1100
committerDarren Tucker <dtucker@zip.com.au>2004-02-06 16:17:51 +1100
commite45674ae8026b9399fc0778a7e964efbcd093689 (patch)
tree632cae57a5e429a8586661f07a7f592bc4b389ee /openbsd-compat/port-aix.c
parentecc9d46dc53cddb5a220f89e6160b3ca6178bb9c (diff)
- (dtucker) [openbsd-compat/port-aix.c openbsd-compat/port-aix.h] Restore
previous authdb setting after auth calls. Fixes problems with setpcred failing on accounts that use AFS or NIS password registries.
Diffstat (limited to 'openbsd-compat/port-aix.c')
-rw-r--r--openbsd-compat/port-aix.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c
index a9cbf49b0..6fc2ef771 100644
--- a/openbsd-compat/port-aix.c
+++ b/openbsd-compat/port-aix.c
@@ -39,6 +39,10 @@
39extern ServerOptions options; 39extern ServerOptions options;
40extern Buffer loginmsg; 40extern Buffer loginmsg;
41 41
42# ifdef HAVE_SETAUTHDB
43static char old_registry[REGISTRY_SIZE] = "";
44# endif
45
42/* 46/*
43 * AIX has a "usrinfo" area where logname and other stuff is stored - 47 * AIX has a "usrinfo" area where logname and other stuff is stored -
44 * a few applications actually use this and die if it's not set 48 * a few applications actually use this and die if it's not set
@@ -119,6 +123,7 @@ aix_authenticate(const char *name, const char *password, const char *host)
119 xfree(msg); 123 xfree(msg);
120 } 124 }
121 } 125 }
126 aix_restoreauthdb();
122 } 127 }
123 128
124 if (authmsg != NULL) 129 if (authmsg != NULL)
@@ -145,22 +150,21 @@ record_failed_login(const char *user, const char *ttyname)
145# else 150# else
146 loginfailed((char *)user, hostname, (char *)ttyname); 151 loginfailed((char *)user, hostname, (char *)ttyname);
147# endif 152# endif
153 aix_restoreauthdb();
148} 154}
149# endif /* CUSTOM_FAILED_LOGIN */ 155# endif /* CUSTOM_FAILED_LOGIN */
150 156
151/* 157/*
152 * If we have setauthdb, retrieve the password registry for the user's 158 * If we have setauthdb, retrieve the password registry for the user's
153 * account then feed it to setauthdb. This may load registry-specific method 159 * account then feed it to setauthdb. This will mean that subsequent AIX auth
154 * code. If we don't have setauthdb or have already called it this is a no-op. 160 * functions will only use the specified loadable module. If we don't have
161 * setauthdb this is a no-op.
155 */ 162 */
156void 163void
157aix_setauthdb(const char *user) 164aix_setauthdb(const char *user)
158{ 165{
159# ifdef HAVE_SETAUTHDB 166# ifdef HAVE_SETAUTHDB
160 static char *registry = NULL; 167 char *registry;
161
162 if (registry != NULL) /* have already done setauthdb */
163 return;
164 168
165 if (setuserdb(S_READ) == -1) { 169 if (setuserdb(S_READ) == -1) {
166 debug3("%s: Could not open userdb to read", __func__); 170 debug3("%s: Could not open userdb to read", __func__);
@@ -168,12 +172,11 @@ aix_setauthdb(const char *user)
168 } 172 }
169 173
170 if (getuserattr((char *)user, S_REGISTRY, &registry, SEC_CHAR) == 0) { 174 if (getuserattr((char *)user, S_REGISTRY, &registry, SEC_CHAR) == 0) {
171 if (setauthdb(registry, NULL) == 0) 175 if (setauthdb(registry, old_registry) == 0)
172 debug3("%s: AIX/setauthdb set registry %s", __func__, 176 debug3("AIX/setauthdb set registry '%s'", registry);
173 registry);
174 else 177 else
175 debug3("%s: AIX/setauthdb set registry %s failed: %s", 178 debug3("AIX/setauthdb set registry '%s' failed: %s",
176 __func__, registry, strerror(errno)); 179 registry, strerror(errno));
177 } else 180 } else
178 debug3("%s: Could not read S_REGISTRY for user: %s", __func__, 181 debug3("%s: Could not read S_REGISTRY for user: %s", __func__,
179 strerror(errno)); 182 strerror(errno));
@@ -181,6 +184,25 @@ aix_setauthdb(const char *user)
181# endif /* HAVE_SETAUTHDB */ 184# endif /* HAVE_SETAUTHDB */
182} 185}
183 186
187/*
188 * Restore the user's registry settings from old_registry.
189 * Note that if the first aix_setauthdb fails, setauthdb("") is still safe
190 * (it restores the system default behaviour). If we don't have setauthdb,
191 * this is a no-op.
192 */
193void
194aix_restoreauthdb(void)
195{
196# ifdef HAVE_SETAUTHDB
197 if (setauthdb(old_registry, NULL) == 0)
198 debug3("%s: restoring old registry '%s'", __func__,
199 old_registry);
200 else
201 debug3("%s: failed to restore old registry %s", __func__,
202 old_registry);
203# endif /* HAVE_SETAUTHDB */
204}
205
184# endif /* WITH_AIXAUTHENTICATE */ 206# endif /* WITH_AIXAUTHENTICATE */
185 207
186#endif /* _AIX */ 208#endif /* _AIX */