~ubuntu-branches/debian/lenny/cracklib2/lenny

« back to all changes in this revision

Viewing changes to util/packer.c

  • Committer: Bazaar Package Importer
  • Author(s): Jan Dittberner, Steve Langasek, Jan Dittberner
  • Date: 2008-10-16 21:04:24 UTC
  • mfrom: (4.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081016210424-bp06uo8c6xkjabzi
Tags: 2.8.12-8lenny1
[ Steve Langasek ]
* debian/update-cracklib: don't rely on [ -nt ] to return true when
  the second file is non-existent, since this fails under dash.
  LP: #278743.

[ Jan Dittberner ]
* integrate Ubuntu bugfix
* use set -e in debian/cracklib-runtime.preinst to fix lintian warning
  maintainer-script-ignores-errors

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * This program is copyright Alec Muffett 1993. The author disclaims all 
3
 
 * responsibility or liability with respect to it's usage or its effect 
4
 
 * upon hardware or computer systems, and maintains copyright as set out 
5
 
 * in the "LICENCE" document which accompanies distributions of Crack v4.0 
6
 
 * and upwards.
 
2
 * This program is copyright Alec Muffett 1993, portions copyright other authors. 
 
3
 * The authors disclaim all responsibility or liability with respect to it's usage
 
4
 * or its effect upon hardware or computer systems. 
7
5
 */
8
6
 
 
7
#include <stdio.h>
 
8
#include <string.h>
 
9
 
 
10
#define IN_CRACKLIB
 
11
#include "config.h"
 
12
#include "crack.h"
9
13
#include "packer.h"
10
14
 
11
15
int
13
17
    int argc;
14
18
    char *argv[];
15
19
{
16
 
    int32 readed;
17
 
    int32 wrote;
 
20
    uint32_t readed;
 
21
    uint32_t wrote;
18
22
    PWDICT *pwp;
19
23
    char buffer[STRINGSIZE];
 
24
    char *file;
20
25
 
21
26
    if (argc <= 1)
22
27
    {
 
28
        file = DEFAULT_CRACKLIB_DICT;
 
29
    }
 
30
    else 
 
31
    {
 
32
        file = argv[1];
 
33
    }
 
34
 
 
35
    if ( argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) )
 
36
    {
23
37
        fprintf(stderr, "Usage:\t%s dbname\n", argv[0]);
 
38
        fprintf(stderr, "  if dbname is not specified, will use compiled in default of (%s).\n", DEFAULT_CRACKLIB_DICT);
24
39
        return (-1);
25
40
    }
26
41
 
27
 
    if (!(pwp = PWOpen(argv[1], "w")))
 
42
    if (!(pwp = PWOpen(file, "w")))
28
43
    {
29
 
        perror(argv[1]);
 
44
        perror(file);
30
45
        return (-1);
31
46
    }
32
47
 
42
57
 
43
58
        if (!buffer[0])
44
59
        {
45
 
            fprintf(stderr, "skipping line: %lu\n", readed);
 
60
            fprintf(stderr, "skipping line: %u\n", readed);
46
61
            continue;
47
62
        }
48
63
 
49
64
        if (PutPW(pwp, buffer))
50
65
        {
51
 
            fprintf(stderr, "error: PutPW '%s' line %luy\n", buffer, readed);
 
66
            fprintf(stderr, "error: PutPW '%s' line %uy\n", buffer, readed);
52
67
        }
53
68
 
54
69
        wrote++;
56
71
 
57
72
    PWClose(pwp);
58
73
 
59
 
    printf("%lu %lu\n", readed, wrote);
 
74
    printf("%u %u\n", readed, wrote);
60
75
 
61
76
    return (0);
62
77
}