~xnox/ubuntu/quantal/shadow/clear-locks

« back to all changes in this revision

Viewing changes to lib/pwmem.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-05-05 09:45:21 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505094521-wpk2wn3q7957tlah
Tags: 1:4.1.3.1-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Ubuntu specific:
    + debian/login.defs: use SHA512 by default for password crypt routine.
  - debian/patches/stdout-encrypted-password.patch: chpasswd can report
    password hashes on stdout (debian bug 505640).
  - debian/login.pam: Enable SELinux support (debian bug 527106).
  - debian/securetty.linux: support Freescale MX-series (debian bug 527095).
* Add debian/patches/300_lastlog_failure: fixed upstream (debian bug 524873).
* Drop debian/patches/593_omit_lastchange_field_if_clock_is_misset: fixed
  upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1990 - 1994, Julianne Frances Haugh
 
3
 * Copyright (c) 1996 - 2000, Marek Michałkiewicz
 
4
 * Copyright (c) 2001       , Michał Moskal
 
5
 * Copyright (c) 2003 - 2005, Tomasz Kłoczko
 
6
 * Copyright (c) 2007       , Nicolas François
 
7
 * All rights reserved.
 
8
 *
 
9
 * Redistribution and use in source and binary forms, with or without
 
10
 * modification, are permitted provided that the following conditions
 
11
 * are met:
 
12
 * 1. Redistributions of source code must retain the above copyright
 
13
 *    notice, this list of conditions and the following disclaimer.
 
14
 * 2. Redistributions in binary form must reproduce the above copyright
 
15
 *    notice, this list of conditions and the following disclaimer in the
 
16
 *    documentation and/or other materials provided with the distribution.
 
17
 * 3. The name of the copyright holders or contributors may not be used to
 
18
 *    endorse or promote products derived from this software without
 
19
 *    specific prior written permission.
 
20
 *
 
21
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
22
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
23
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 
24
 * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
 
25
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
27
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
28
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
29
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
30
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
31
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
32
 */
1
33
 
2
34
#include <config.h>
3
35
 
4
 
#ident "$Id: pwmem.c 1443 2007-11-23 19:44:57Z nekral-guest $"
 
36
#ident "$Id: pwmem.c 2301 2008-08-30 18:32:19Z nekral-guest $"
5
37
 
 
38
#include <stdio.h>
6
39
#include "prototypes.h"
7
40
#include "defines.h"
8
 
#include <pwd.h>
9
 
#include <stdio.h>
10
41
#include "pwio.h"
11
42
 
12
43
struct passwd *__pw_dup (const struct passwd *pwent)
13
44
{
14
45
        struct passwd *pw;
15
46
 
16
 
        if (!(pw = (struct passwd *) malloc (sizeof *pw)))
 
47
        pw = (struct passwd *) malloc (sizeof *pw);
 
48
        if (NULL == pw) {
17
49
                return NULL;
 
50
        }
18
51
        *pw = *pwent;
19
 
        if (!(pw->pw_name = strdup (pwent->pw_name)))
20
 
                return NULL;
21
 
        if (!(pw->pw_passwd = strdup (pwent->pw_passwd)))
22
 
                return NULL;
23
 
        if (!(pw->pw_gecos = strdup (pwent->pw_gecos)))
24
 
                return NULL;
25
 
        if (!(pw->pw_dir = strdup (pwent->pw_dir)))
26
 
                return NULL;
27
 
        if (!(pw->pw_shell = strdup (pwent->pw_shell)))
28
 
                return NULL;
 
52
        pw->pw_name = strdup (pwent->pw_name);
 
53
        if (NULL == pw->pw_name) {
 
54
                return NULL;
 
55
        }
 
56
        pw->pw_passwd = strdup (pwent->pw_passwd);
 
57
        if (NULL == pw->pw_passwd) {
 
58
                return NULL;
 
59
        }
 
60
        pw->pw_gecos = strdup (pwent->pw_gecos);
 
61
        if (NULL == pw->pw_gecos) {
 
62
                return NULL;
 
63
        }
 
64
        pw->pw_dir = strdup (pwent->pw_dir);
 
65
        if (NULL == pw->pw_dir) {
 
66
                return NULL;
 
67
        }
 
68
        pw->pw_shell = strdup (pwent->pw_shell);
 
69
        if (NULL == pw->pw_shell) {
 
70
                return NULL;
 
71
        }
 
72
 
29
73
        return pw;
30
74
}
31
75