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

« back to all changes in this revision

Viewing changes to libmisc/obscure.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:
2
2
 * Copyright (c) 1989 - 1994, Julianne Frances Haugh
3
3
 * Copyright (c) 1996 - 1999, Marek Michałkiewicz
4
4
 * Copyright (c) 2003 - 2005, Tomasz Kłoczko
5
 
 * Copyright (c) 2007 - 2008, Nicolas François
 
5
 * Copyright (c) 2007 - 2010, Nicolas François
6
6
 * All rights reserved.
7
7
 *
8
8
 * Redistribution and use in source and binary forms, with or without
34
34
 
35
35
#ifndef USE_PAM
36
36
 
37
 
#ident "$Id: obscure.c 2791 2009-04-24 23:04:27Z nekral-guest $"
 
37
#ident "$Id: obscure.c 3232 2010-08-22 19:13:53Z nekral-guest $"
38
38
 
39
39
 
40
40
/*
69
69
 * more than half of the characters are different ones.
70
70
 */
71
71
 
72
 
static bool similar (const char *old, const char *new)
 
72
static bool similar (/*@notnull@*/const char *old, /*@notnull@*/const char *new)
73
73
{
74
74
        int i, j;
75
75
 
100
100
 * a nice mix of characters.
101
101
 */
102
102
 
103
 
static int simple (unused const char *old, const char *new)
 
103
static bool simple (unused const char *old, const char *new)
104
104
{
105
105
        bool digits = false;
106
106
        bool uppers = false;
147
147
        return true;
148
148
}
149
149
 
150
 
static char *str_lower (char *string)
 
150
static char *str_lower (/*@returned@*/char *string)
151
151
{
152
152
        char *cp;
153
153
 
157
157
        return string;
158
158
}
159
159
 
160
 
static const char *password_check (const char *old, const char *new,
161
 
                                   const struct passwd *pwdp)
 
160
static /*@observer@*//*@null@*/const char *password_check (
 
161
        /*@notnull@*/const char *old,
 
162
        /*@notnull@*/const char *new,
 
163
        /*@notnull@*/const struct passwd *pwdp)
162
164
{
163
165
        const char *msg = NULL;
164
166
        char *oldmono, *newmono, *wrapped;
219
221
        return msg;
220
222
}
221
223
 
222
 
/*ARGSUSED*/
223
 
static const char *obscure_msg (const char *old, const char *new,
224
 
                                    const struct passwd *pwdp)
 
224
static /*@observer@*//*@null@*/const char *obscure_msg (
 
225
        /*@notnull@*/const char *old,
 
226
        /*@notnull@*/const char *new,
 
227
        /*@notnull@*/const struct passwd *pwdp)
225
228
{
226
229
        size_t maxlen, oldlen, newlen;
227
230
        char *new1, *old1;
228
231
        const char *msg;
229
 
        char *result;
 
232
        const char *result;
230
233
 
231
234
        oldlen = strlen (old);
232
235
        newlen = strlen (new);
304
307
 *      check passwords.
305
308
 */
306
309
 
307
 
int obscure (const char *old, const char *new, const struct passwd *pwdp)
 
310
bool obscure (const char *old, const char *new, const struct passwd *pwdp)
308
311
{
309
312
        const char *msg = obscure_msg (old, new, pwdp);
310
313
 
311
314
        if (NULL != msg) {
312
315
                printf (_("Bad password: %s.  "), msg);
313
 
                return 0;
 
316
                return false;
314
317
        }
315
 
        return 1;
 
318
        return true;
316
319
}
317
320
 
318
321
#else                           /* !USE_PAM */