~zulcss/ubuntu/lucid/likewise-open/likewise-open-sru

« back to all changes in this revision

Viewing changes to samba/source/winbindd/likewise/idmap_lwicompat_v2.c

  • Committer: Bazaar Package Importer
  • Author(s): Rick Clark
  • Date: 2008-08-27 08:56:20 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080827085620-5q0f58b9qtog9myq
Tags: 4.1.0.2956-0ubuntu1
* missing-likewise-logo.diff: removed
* fixed copyright notice
* updated Standards-Version to 3.8.0
* removed path from command in prerm
* removed stop in S runlevel

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#define _IDMAP_H_
27
27
 
28
 
/* Version 2 was used in Samba 3.0.0 - 3.0.24 */
 
28
/* Version 2 was used in Samba 3.0.0 - 3.0.22 */
29
29
 
30
30
#define SMB_IDMAP_INTERFACE_VERSION 2
31
31
 
34
34
#define ID_GROUPID      0x02
35
35
#define ID_OTHER        0x04
36
36
 
 
37
#define ID_TYPEMASK     0x0f
 
38
 
37
39
struct idmap_methods;
38
40
struct idmap_alloc_methods;
39
41
 
54
56
        void (*status) (void);
55
57
};
56
58
 
 
59
const char* sid_string_static(const DOM_SID*);
 
60
 
57
61
/*********************************************************************
58
62
 ********************************************************************/
59
63
 
124
128
        NSS_STATUS result;
125
129
        struct winbindd_request request;
126
130
        struct winbindd_response response;
127
 
        struct unixid *ret_id = (struct unixid *)response.extra_data.data;
 
131
        enum winbindd_cmd cmd;
 
132
        int query_type = (*type) & ID_TYPEMASK;
128
133
 
129
134
        ZERO_STRUCT(request);
130
135
        ZERO_STRUCT(response);
131
136
 
132
 
        request.extra_len = sizeof(DOM_SID);
133
 
        request.extra_data.data = (char *)sid;
 
137
        fstrcpy(request.data.sid, sid_string_static(sid));
 
138
 
 
139
        switch (query_type) {
 
140
        case ID_USERID:
 
141
                cmd = WINBINDD_SID_TO_UID;
 
142
                break;
 
143
        case ID_GROUPID:
 
144
                cmd = WINBINDD_SID_TO_GID;
 
145
                break;
 
146
        default:
 
147
                DEBUG(4,("lwi_get_id_from_sid: Unknown query type (%u)\n", query_type));
 
148
                return NT_STATUS_INVALID_PARAMETER;
 
149
        }
134
150
 
135
151
        /* Make request */
136
152
 
137
 
        result = winbindd_request_response(WINBINDD_SIDS_TO_XIDS,
 
153
        result = winbindd_request_response(cmd,
138
154
                                           &request, &response);
139
155
 
140
156
        /* Copy out result */
142
158
        if (result != NSS_STATUS_SUCCESS)
143
159
                return NT_STATUS_NONE_MAPPED;
144
160
 
145
 
        ret_id = (struct unixid *)response.extra_data.data;
146
 
 
147
 
        if (ret_id->type == -1)
148
 
                return NT_STATUS_NONE_MAPPED;
149
 
 
150
 
        switch (ret_id->type) {
151
 
        case ID_TYPE_UID:
152
 
                *type = ID_USERID;
153
 
                id->uid = ret_id->id;
154
 
                break;
155
 
        case ID_TYPE_GID:
156
 
                *type = ID_GROUPID;
157
 
                id->gid = ret_id->id;
158
 
                break;
159
 
        default:
160
 
                DEBUG(2,
161
 
                      ("lwi_get_id_from_sid: Unknown return type of ID (%d)\n",
162
 
                       ret_id->type));
163
 
                SAFE_FREE(response.extra_data.data);
164
 
                return NT_STATUS_NONE_MAPPED;
165
 
        }
 
161
        /* Let the union work it out */
 
162
        id->uid = response.data.uid;
166
163
 
167
164
        SAFE_FREE(response.extra_data.data);
168
165