]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/external/kerberos_ldap_group/support_netbios.cc
2 * Copyright (C) 1996-2017 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 * -----------------------------------------------------------------------------
12 * Author: Markus Moeller (markus_moeller at compuserve.com)
14 * Copyright (C) 2007 Markus Moeller. All rights reserved.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
30 * -----------------------------------------------------------------------------
40 struct ndstruct
*init_nd(void);
41 void free_nd(struct ndstruct
*ndsp
);
45 struct ndstruct
*ndsp
;
46 ndsp
= (struct ndstruct
*) xmalloc(sizeof(struct ndstruct
));
54 free_nd(struct ndstruct
*ndsp
)
57 struct ndstruct
*ndspn
= ndsp
->next
;
66 create_nd(struct main_args
*margs
)
70 struct ndstruct
*ndsp
= NULL
, *ndspn
= NULL
;
72 * netbios list format:
74 * nlist=Pattern1[:Pattern2]
76 * Pattern=NetbiosName@Domain Netbios Name for a specific Kerberos domain
77 * ndstruct.domain=Domain, ndstruct.netbios=NetbiosName
83 debug((char *) "%s| %s: DEBUG: Netbios list %s\n", LogTime(), PROGRAM
, margs
->nlist
? margs
->nlist
: "NULL");
87 debug((char *) "%s| %s: DEBUG: No netbios names defined.\n", LogTime(), PROGRAM
);
90 while (*p
) { /* loop over group list */
91 if (*p
== '\n' || *p
== '\r') { /* Ignore CR and LF if exist */
95 if (*p
== '@') { /* end of group name - start of domain name */
96 if (p
== np
) { /* empty group name not allowed */
97 debug((char *) "%s| %s: DEBUG: No netbios name defined for domain %s\n", LogTime(), PROGRAM
, p
);
101 if (dp
) { /* end of domain name - twice */
102 debug((char *) "%s| %s: @ is not allowed in netbios name %s@%s\n",LogTime(), PROGRAM
,np
,dp
);
109 ndsp
->netbios
= xstrdup(np
);
111 dp
= p
; /* after @ starts new domain name */
112 } else if (*p
== ':') { /* end of group name or end of domain name */
113 if (p
== np
) { /* empty group name not allowed */
114 debug((char *) "%s| %s: DEBUG: No netbios name defined for domain %s\n", LogTime(), PROGRAM
, p
);
120 if (dp
) { /* end of domain name */
121 ndsp
->domain
= xstrdup(dp
);
123 } else { /* end of group name and no domain name */
125 ndsp
->netbios
= xstrdup(np
);
129 np
= p
; /* after : starts new group name */
130 if (!ndsp
->domain
|| !strcmp(ndsp
->domain
, "")) {
131 debug((char *) "%s| %s: DEBUG: No domain defined for netbios name %s\n", LogTime(), PROGRAM
, ndsp
->netbios
);
135 debug((char *) "%s| %s: DEBUG: Netbios name %s Domain %s\n", LogTime(), PROGRAM
, ndsp
->netbios
, ndsp
->domain
);
139 if (p
== np
) { /* empty group name not allowed */
140 debug((char *) "%s| %s: DEBUG: No netbios name defined for domain %s\n", LogTime(), PROGRAM
, p
);
144 if (dp
) { /* end of domain name */
145 ndsp
->domain
= xstrdup(dp
);
146 } else { /* end of group name and no domain name */
148 ndsp
->netbios
= xstrdup(np
);
151 if (!ndsp
->domain
|| !strcmp(ndsp
->domain
, "")) {
152 debug((char *) "%s| %s: DEBUG: No domain defined for netbios name %s\n", LogTime(), PROGRAM
, ndsp
->netbios
);
156 debug((char *) "%s| %s: DEBUG: Netbios name %s Domain %s\n", LogTime(), PROGRAM
, ndsp
->netbios
, ndsp
->domain
);
163 get_netbios_name(struct main_args
*margs
, char *netbios
)
168 while (nd
&& netbios
) {
169 debug((char *) "%s| %s: DEBUG: Netbios domain loop: netbios@domain %s@%s\n", LogTime(), PROGRAM
, nd
->netbios
, nd
->domain
);
170 if (nd
->netbios
&& !strcasecmp(nd
->netbios
, netbios
)) {
171 debug((char *) "%s| %s: DEBUG: Found netbios@domain %s@%s\n", LogTime(), PROGRAM
, nd
->netbios
, nd
->domain
);