~ubuntu-branches/ubuntu/quantal/shadow/quantal

« back to all changes in this revision

Viewing changes to lib/groupio.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2010-11-24 13:42:42 UTC
  • mfrom: (1.1.9 upstream) (18.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20101124134242-832f4tew5s81ntj7
Tags: 1:4.1.4.2+svn3283-2ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Ubuntu specific:
    + debian/login.defs: use SHA512 by default for password crypt routine.
  - debian/{source_shadow.py,rules}: Add apport hook
  - debian/rules: fix FTBFS from newer libtools
  - debian/patches/495_stdout-encrypted-password: chpasswd can report
    password hashes on stdout (Debian bug 505640).
  - Rework 495_stdout-encrypted-password to cope with chpasswd using PAM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * Copyright (c) 1996 - 2000, Marek Michałkiewicz
4
4
 * Copyright (c) 2001       , Michał Moskal
5
5
 * Copyright (c) 2005       , Tomasz Kłoczko
6
 
 * Copyright (c) 2007 - 2009, Nicolas François
 
6
 * Copyright (c) 2007 - 2010, Nicolas François
7
7
 * All rights reserved.
8
8
 *
9
9
 * Redistribution and use in source and binary forms, with or without
33
33
 
34
34
#include <config.h>
35
35
 
36
 
#ident "$Id: groupio.c 2822 2009-04-27 20:18:00Z nekral-guest $"
 
36
#ident "$Id: groupio.c 3231 2010-08-22 13:04:54Z nekral-guest $"
37
37
 
38
38
#include <assert.h>
39
39
#include <stdio.h>
382
382
                struct commonio_entry *new;
383
383
                struct group *new_gptr;
384
384
                unsigned int members = 0;
 
385
                unsigned int i;
385
386
 
386
387
                /* Check if this group must be split */
387
 
                if (!gr->changed)
388
 
                        continue;
389
 
                if (NULL == gptr)
390
 
                        continue;
 
388
                if (!gr->changed) {
 
389
                        continue;
 
390
                }
 
391
                if (NULL == gptr) {
 
392
                        continue;
 
393
                }
391
394
                for (members = 0; NULL != gptr->gr_mem[members]; members++);
392
 
                if (members <= max_members)
 
395
                if (members <= max_members) {
393
396
                        continue;
 
397
                }
394
398
 
395
399
                new = (struct commonio_entry *) malloc (sizeof *new);
396
400
                if (NULL == new) {
408
412
                new->changed = true;
409
413
 
410
414
                /* Enforce the maximum number of members on gptr */
411
 
                gptr->gr_mem[max_members] = NULL;
 
415
                for (i = max_members; NULL != gptr->gr_mem[i]; i++) {
 
416
                        free (gptr->gr_mem[i]);
 
417
                        gptr->gr_mem[i] = NULL;
 
418
                }
 
419
                /* Shift all the members */
412
420
                /* The number of members in new_gptr will be check later */
413
 
                new_gptr->gr_mem = &new_gptr->gr_mem[max_members];
 
421
                for (i = 0; NULL != new_gptr->gr_mem[i + max_members]; i++) {
 
422
                        if (NULL != new_gptr->gr_mem[i]) {
 
423
                                free (new_gptr->gr_mem[i]);
 
424
                        }
 
425
                        new_gptr->gr_mem[i] = new_gptr->gr_mem[i + max_members];
 
426
                        new_gptr->gr_mem[i + max_members] = NULL;
 
427
                }
 
428
                for (; NULL != new_gptr->gr_mem[i]; i++) {
 
429
                        free (new_gptr->gr_mem[i]);
 
430
                        new_gptr->gr_mem[i] = NULL;
 
431
                }
414
432
 
415
433
                /* insert the new entry in the list */
416
434
                new->prev = gr;