]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/basic/NIS/basic_nis_auth.cc
2 * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 * Adapted By Rabellino Sergio (rabellino@di.unito.it) For Solaris 2.x
11 * From NCSA Authentication module
15 #include "auth/basic/NIS/nis_support.h"
26 #include <sys/types.h>
36 main(int argc
, char **argv
)
41 char *user
, *passwd
, *p
;
47 fprintf(stderr
, "Usage: basic_nis_auth <domainname> <nis map for password>\n");
48 fprintf(stderr
, "\n");
49 fprintf(stderr
, "Example basic_nis_auth mydomain.com passwd.byname\n");
55 while (fgets(buf
, 256, stdin
) != NULL
) {
56 if ((p
= strchr(buf
, '\n')) != NULL
)
57 *p
= '\0'; /* strip \n */
59 if ((user
= strtok(buf
, " ")) == NULL
) {
63 if ((passwd
= strtok(NULL
, "")) == NULL
) {
68 rfc1738_unescape(user
);
69 rfc1738_unescape(passwd
);
71 nispasswd
= get_nis_password(user
, nisdomain
, nismap
);
74 /* User does not exist */
75 printf("ERR No such user\n");
81 if ((crypted
= crypt(passwd
, nispasswd
)) && strcmp(nispasswd
, crypted
) == 0) {
82 /* All ok !, thanks... */
85 /* Password incorrect */
86 printf("ERR Wrong password\n");
89 /* Password incorrect */
90 printf("BH message=\"Missing crypto capability\"\n");