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

« back to all changes in this revision

Viewing changes to samba/source/nsswitch/libwbclient/wbc_idmap.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:
243
243
 * @return #wbcErr
244
244
 **/
245
245
 
246
 
wbcErr wbcAllocateGid(uid_t *pgid)
 
246
wbcErr wbcAllocateGid(gid_t *pgid)
247
247
{
248
248
        struct winbindd_request request;
249
249
        struct winbindd_response response;
272
272
        return wbc_status;
273
273
}
274
274
 
 
275
/* we can't include smb.h here... */
 
276
#define _ID_TYPE_UID 1
 
277
#define _ID_TYPE_GID 2
 
278
 
 
279
/** @brief Set an user id mapping
 
280
 *
 
281
 * @param uid       Uid of the desired mapping.
 
282
 * @param *sid      Pointer to the sid of the diresired mapping.
 
283
 *
 
284
 * @return #wbcErr
 
285
 **/
 
286
wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid)
 
287
{
 
288
        struct winbindd_request request;
 
289
        struct winbindd_response response;
 
290
        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
 
291
        char *sid_string = NULL;
 
292
 
 
293
        if (!sid) {
 
294
                return WBC_ERR_INVALID_PARAM;
 
295
        }
 
296
 
 
297
        /* Initialise request */
 
298
 
 
299
        ZERO_STRUCT(request);
 
300
        ZERO_STRUCT(response);
 
301
 
 
302
        /* Make request */
 
303
 
 
304
        request.data.dual_idmapset.id = uid;
 
305
        request.data.dual_idmapset.type = _ID_TYPE_UID;
 
306
 
 
307
        wbc_status = wbcSidToString(sid, &sid_string);
 
308
        BAIL_ON_WBC_ERROR(wbc_status);
 
309
 
 
310
        strncpy(request.data.dual_idmapset.sid, sid_string,
 
311
                sizeof(request.data.dual_idmapset.sid)-1);
 
312
        wbcFreeMemory(sid_string);
 
313
 
 
314
        wbc_status = wbcRequestResponse(WINBINDD_SET_MAPPING,
 
315
                                        &request, &response);
 
316
        BAIL_ON_WBC_ERROR(wbc_status);
 
317
 
 
318
 done:
 
319
        return wbc_status;
 
320
}
 
321
 
 
322
/** @brief Set a group id mapping
 
323
 *
 
324
 * @param gid       Gid of the desired mapping.
 
325
 * @param *sid      Pointer to the sid of the diresired mapping.
 
326
 *
 
327
 * @return #wbcErr
 
328
 **/
 
329
wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid)
 
330
{
 
331
        struct winbindd_request request;
 
332
        struct winbindd_response response;
 
333
        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
 
334
        char *sid_string = NULL;
 
335
 
 
336
        if (!sid) {
 
337
                return WBC_ERR_INVALID_PARAM;
 
338
        }
 
339
 
 
340
        /* Initialise request */
 
341
 
 
342
        ZERO_STRUCT(request);
 
343
        ZERO_STRUCT(response);
 
344
 
 
345
        /* Make request */
 
346
 
 
347
        request.data.dual_idmapset.id = gid;
 
348
        request.data.dual_idmapset.type = _ID_TYPE_GID;
 
349
 
 
350
        wbc_status = wbcSidToString(sid, &sid_string);
 
351
        BAIL_ON_WBC_ERROR(wbc_status);
 
352
 
 
353
        strncpy(request.data.dual_idmapset.sid, sid_string,
 
354
                sizeof(request.data.dual_idmapset.sid)-1);
 
355
        wbcFreeMemory(sid_string);
 
356
 
 
357
        wbc_status = wbcRequestResponse(WINBINDD_SET_MAPPING,
 
358
                                        &request, &response);
 
359
        BAIL_ON_WBC_ERROR(wbc_status);
 
360
 
 
361
 done:
 
362
        return wbc_status;
 
363
}
 
364
 
 
365
/** @brief Set the highwater mark for allocated uids.
 
366
 *
 
367
 * @param uid_hwm      The new uid highwater mark value
 
368
 *
 
369
 * @return #wbcErr
 
370
 **/
 
371
wbcErr wbcSetUidHwm(uid_t uid_hwm)
 
372
{
 
373
        struct winbindd_request request;
 
374
        struct winbindd_response response;
 
375
        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
 
376
 
 
377
        /* Initialise request */
 
378
 
 
379
        ZERO_STRUCT(request);
 
380
        ZERO_STRUCT(response);
 
381
 
 
382
        /* Make request */
 
383
 
 
384
        request.data.dual_idmapset.id = uid_hwm;
 
385
        request.data.dual_idmapset.type = _ID_TYPE_UID;
 
386
 
 
387
        wbc_status = wbcRequestResponse(WINBINDD_SET_HWM,
 
388
                                        &request, &response);
 
389
        BAIL_ON_WBC_ERROR(wbc_status);
 
390
 
 
391
 done:
 
392
        return wbc_status;
 
393
}
 
394
 
 
395
/** @brief Set the highwater mark for allocated gids.
 
396
 *
 
397
 * @param uid_hwm      The new gid highwater mark value
 
398
 *
 
399
 * @return #wbcErr
 
400
 **/
 
401
wbcErr wbcSetGidHwm(gid_t gid_hwm)
 
402
{
 
403
        struct winbindd_request request;
 
404
        struct winbindd_response response;
 
405
        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
 
406
 
 
407
        /* Initialise request */
 
408
 
 
409
        ZERO_STRUCT(request);
 
410
        ZERO_STRUCT(response);
 
411
 
 
412
        /* Make request */
 
413
 
 
414
        request.data.dual_idmapset.id = gid_hwm;
 
415
        request.data.dual_idmapset.type = _ID_TYPE_GID;
 
416
 
 
417
        wbc_status = wbcRequestResponse(WINBINDD_SET_HWM,
 
418
                                        &request, &response);
 
419
        BAIL_ON_WBC_ERROR(wbc_status);
 
420
 
 
421
 done:
 
422
        return wbc_status;
 
423
}