~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to helpers/basic_auth/mswin_sspi/valid.c

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2010-05-04 11:15:49 UTC
  • mfrom: (1.3.1 upstream)
  • mto: (20.3.1 squeeze) (21.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20100504111549-1apjh2g5sndki4te
Tags: upstream-3.1.3
ImportĀ upstreamĀ versionĀ 3.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
22
 * GNU General Public License for more details.
23
 
 
 
23
 
24
24
 * You should have received a copy of the GNU General Public License
25
25
 * along with this program; if not, write to the Free Software
26
26
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
63
63
    DWORD i;
64
64
    DWORD dwTotalCount = 0;
65
65
 
66
 
/* Convert ANSI User Name and Group to Unicode */
 
66
    /* Convert ANSI User Name and Group to Unicode */
67
67
 
68
68
    MultiByteToWideChar(CP_ACP, 0, UserName,
69
 
        strlen(UserName) + 1, wszUserName,
70
 
        sizeof(wszUserName) / sizeof(wszUserName[0]));
 
69
                        strlen(UserName) + 1, wszUserName,
 
70
                        sizeof(wszUserName) / sizeof(wszUserName[0]));
71
71
    MultiByteToWideChar(CP_ACP, 0, Group,
72
 
        strlen(Group) + 1, wszGroup, sizeof(wszGroup) / sizeof(wszGroup[0]));
 
72
                        strlen(Group) + 1, wszGroup, sizeof(wszGroup) / sizeof(wszGroup[0]));
73
73
 
74
74
    /*
75
 
     * Call the NetUserGetLocalGroups function 
76
 
         * specifying information level 0.
77
 
         * 
78
 
         * The LG_INCLUDE_INDIRECT flag specifies that the 
79
 
         * function should also return the names of the local 
80
 
         * groups in which the user is indirectly a member.
81
 
         */
82
 
        nStatus = NetUserGetLocalGroups(NULL,
83
 
            wszUserName,
84
 
            dwLevel,
85
 
            dwFlags,
86
 
            (LPBYTE *) & pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries);
87
 
        /*
88
 
         * If the call succeeds,
89
 
         */
 
75
     * Call the NetUserGetLocalGroups function
 
76
     * specifying information level 0.
 
77
     *
 
78
     * The LG_INCLUDE_INDIRECT flag specifies that the
 
79
     * function should also return the names of the local
 
80
     * groups in which the user is indirectly a member.
 
81
     */
 
82
    nStatus = NetUserGetLocalGroups(NULL,
 
83
                                    wszUserName,
 
84
                                    dwLevel,
 
85
                                    dwFlags,
 
86
                                    (LPBYTE *) & pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries);
 
87
    /*
 
88
     * If the call succeeds,
 
89
     */
90
90
    if (nStatus == NERR_Success) {
91
 
        if ((pTmpBuf = pBuf) != NULL) {
92
 
            for (i = 0; i < dwEntriesRead; i++) {
93
 
                if (pTmpBuf == NULL) {
94
 
                    result = FALSE;
95
 
                    break;
96
 
                }
97
 
                if (wcscmp(pTmpBuf->lgrui0_name, wszGroup) == 0) {
98
 
                    result = TRUE;
99
 
                    break;
100
 
                }
101
 
                pTmpBuf++;
102
 
                dwTotalCount++;
103
 
            }
104
 
        }
 
91
        if ((pTmpBuf = pBuf) != NULL) {
 
92
            for (i = 0; i < dwEntriesRead; i++) {
 
93
                if (pTmpBuf == NULL) {
 
94
                    result = FALSE;
 
95
                    break;
 
96
                }
 
97
                if (wcscmp(pTmpBuf->lgrui0_name, wszGroup) == 0) {
 
98
                    result = TRUE;
 
99
                    break;
 
100
                }
 
101
                pTmpBuf++;
 
102
                dwTotalCount++;
 
103
            }
 
104
        }
105
105
    } else
106
 
            result = FALSE;
107
 
/*
108
 
 * Free the allocated memory.
109
 
 */
 
106
        result = FALSE;
 
107
    /*
 
108
     * Free the allocated memory.
 
109
     */
110
110
    if (pBuf != NULL)
111
 
        NetApiBufferFree(pBuf);
 
111
        NetApiBufferFree(pBuf);
112
112
    return result;
113
113
}
114
114
 
125
125
    int result = NTV_SERVER_ERROR;
126
126
    size_t i;
127
127
    char NTDomain[256];
128
 
    char *domain_qualify;
 
128
    char *domain_qualify = NULL;
129
129
    char DomainUser[256];
130
130
    char User[256];
131
131
 
137
137
            break;
138
138
    }
139
139
    if (domain_qualify == NULL) {
140
 
        strcpy(User, NTDomain);
141
 
        strcpy(NTDomain, Default_NTDomain);
 
140
        strcpy(User, NTDomain);
 
141
        strcpy(NTDomain, Default_NTDomain);
142
142
    } else {
143
 
        strcpy(User, domain_qualify + 1);
144
 
        domain_qualify[0] = '\0';
 
143
        strcpy(User, domain_qualify + 1);
 
144
        domain_qualify[0] = '\0';
145
145
    }
146
146
    /* Log the client on to the local computer. */
147
147
    if (!SSP_LogonUser(User, Password, NTDomain)) {
148
 
        result = NTV_LOGON_ERROR;
 
148
        result = NTV_LOGON_ERROR;
149
149
        errormsg = NTV_LOGON_ERROR_MSG;
150
150
        debug("%s\n", errormsg);
151
151
    } else {
152
 
        result = NTV_NO_ERROR;
153
 
        if (strcmp(NTDomain, NTV_DEFAULT_DOMAIN) == 0)
154
 
            strcpy(DomainUser, User);
155
 
        else {
156
 
            strcpy(DomainUser, NTDomain);
157
 
            strcat(DomainUser, "\\");
158
 
            strcat(DomainUser, User);
159
 
        }
160
 
        if (UseAllowedGroup) {
161
 
            if (!Valid_Group(DomainUser, NTAllowedGroup)) {
162
 
                result = NTV_GROUP_ERROR;
163
 
                errormsg = NTV_GROUP_ERROR_MSG;
164
 
                debug("%s\n", errormsg);
165
 
            }
166
 
        }
167
 
        if (UseDisallowedGroup) {
168
 
            if (Valid_Group(DomainUser, NTDisAllowedGroup)) {
169
 
                result = NTV_GROUP_ERROR;
170
 
                errormsg = NTV_GROUP_ERROR_MSG;
171
 
                debug("%s\n", errormsg);
172
 
            }
173
 
        }
 
152
        result = NTV_NO_ERROR;
 
153
        if (strcmp(NTDomain, NTV_DEFAULT_DOMAIN) == 0)
 
154
            strcpy(DomainUser, User);
 
155
        else {
 
156
            strcpy(DomainUser, NTDomain);
 
157
            strcat(DomainUser, "\\");
 
158
            strcat(DomainUser, User);
 
159
        }
 
160
        if (UseAllowedGroup) {
 
161
            if (!Valid_Group(DomainUser, NTAllowedGroup)) {
 
162
                result = NTV_GROUP_ERROR;
 
163
                errormsg = NTV_GROUP_ERROR_MSG;
 
164
                debug("%s\n", errormsg);
 
165
            }
 
166
        }
 
167
        if (UseDisallowedGroup) {
 
168
            if (Valid_Group(DomainUser, NTDisAllowedGroup)) {
 
169
                result = NTV_GROUP_ERROR;
 
170
                errormsg = NTV_GROUP_ERROR_MSG;
 
171
                debug("%s\n", errormsg);
 
172
            }
 
173
        }
174
174
    }
175
175
    return result;
176
176
}