squid-
cache.org
Optimising Web Delivery
Docs
Download
Donate
Support
About
Contact
Shop
Blog
src
auth
basic
NIS
nis_support.cc
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3
*
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.
7
*/
8
9
/*
10
* Written By Rabellino Sergio (rabellino@di.unito.it) For Solaris 2.x
11
*/
12
#include "
squid.h
"
13
14
#include <cstdlib>
15
#include <cstring>
16
#if HAVE_SYSLOG_H
17
#include <syslog.h>
18
#endif
19
#if HAVE_SYS_TYPES_H
20
#include <sys/types.h>
21
#endif
22
#if HAVE_RPC_RPC_H
23
#include <rpc/rpc.h>
24
#endif
25
26
#if _SQUID_FREEBSD_ && !defined(BOOL_DEFINED)
27
// BUG: FreeBSD rpcsvc/yp_* headers try to redefine bool unless we match their non-standard hack.
28
#define BOOL_DEFINED
29
#endif
30
31
#if HAVE_RPCSVC_YPCLNT_H
32
#include <rpcsvc/ypclnt.h>
33
#endif
34
#if HAVE_RPCSVC_YP_PROT_H
35
#include <rpcsvc/yp_prot.h>
36
#endif
37
38
#include "
auth/basic/NIS/nis_support.h
"
39
40
#define NO_YPERR 0
/* There is no error */
41
42
char
*
43
get_nis_password
(
char
*user,
char
*nisdomain,
char
*nismap)
44
{
45
static
char
*val =
nullptr
;
46
char
*password =
nullptr
;
47
int
vallen, res;
48
49
#ifdef DEBUG
50
printf(
"Domain is set to %s\n"
, nisdomain);
51
printf(
"YP Map is set to %s\n"
, nismap);
52
#endif
53
54
/* Free last entry */
55
if
(val) {
56
free(val);
57
val =
nullptr
;
58
}
59
60
/* Get NIS entry */
61
res = yp_match(nisdomain, nismap, user, strlen(user), &val, &vallen);
62
63
switch
(res) {
64
case
NO_YPERR
:
65
/* username = */
66
(void) strtok(val,
":"
);
67
password = strtok(
nullptr
,
",:"
);
68
return
password;
69
case
YPERR_YPBIND:
70
syslog(LOG_ERR,
"Squid Authentication through ypbind failure: can't communicate with ypbind"
);
71
return
nullptr
;
72
case
YPERR_KEY:
/* No such key in map */
73
return
nullptr
;
74
default
:
75
return
nullptr
;
76
}
77
}
78
get_nis_password
char * get_nis_password(char *user, char *nisdomain, char *nismap)
Definition:
nis_support.cc:43
NO_YPERR
#define NO_YPERR
Definition:
nis_support.cc:40
nis_support.h
squid.h
Introduction
About Squid
Why Squid?
Squid Developers
How to Donate
How to Help Out
Getting Squid
Squid Source Packages
Squid Deployment Case-Studies
Squid Software Foundation
Documentation
Quick Setup
Configuration:
Reference
Examples
FAQ
and
Wiki
Guide Books:
Beginners
Definitive
Non-English
More...
Support
Security Advisories
Bugzilla Database
Mailing lists
Contacting us
Commercial services
Project Sponsors
Squid-based products
Miscellaneous
Developer Resources
Related Writings
Related Software:
Authenticators
Ecap
Icap
Ident
Log Analysis
Monitor
Proxies
Redirectors
General
Squid Artwork
Web Site Translations
Japanese
Mirrors
Website:
gr
il
pl
...
full list
FTP Package Archive