~ubuntu-branches/ubuntu/wily/libuser/wily

« back to all changes in this revision

Viewing changes to samples/homedir.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Habouzit
  • Date: 2006-09-03 21:58:15 UTC
  • mto: (2.1.1 edgy) (1.1.5 upstream) (3.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20060903215815-rtvvfzhaer8ymyp4
Tags: upstream-0.54.6-2.1.dfsg.1
ImportĀ upstreamĀ versionĀ 0.54.6-2.1.dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
17
 */
18
18
 
19
 
#ident "$Id: homedir.c,v 1.6 2004/11/01 10:12:25 mitr Exp $"
 
19
#ident "$Id: homedir.c,v 1.8 2006/05/01 04:51:21 mitr Exp $"
20
20
 
21
21
#ifdef HAVE_CONFIG_H
22
22
#include "config.h"
32
32
main(int argc, char **argv)
33
33
{
34
34
        struct lu_error *error = NULL;
35
 
        int add = 0, mod = 0, rem = 0, c = -1;
 
35
        int add = 0, mod = 0, rem = 0, c;
36
36
 
37
37
        bindtextdomain(PACKAGE, LOCALEDIR);
38
38
        textdomain(PACKAGE);
53
53
                }
54
54
        }
55
55
 
56
 
        if (add
57
 
            && !lu_homedir_populate("/etc/skel", argv[optind], 500, 500,
58
 
                                    0700, &error)) {
59
 
                fprintf(stderr, "populate_homedir(%s) failed: %s\n",
60
 
                        argv[optind], lu_strerror(error));
61
 
                return 1;
 
56
        if (add) {
 
57
                struct lu_context *ctx;
 
58
                struct lu_error *error;
 
59
 
 
60
                error = NULL;
 
61
                ctx = lu_start(NULL, 0, NULL, NULL, lu_prompt_console, NULL,
 
62
                               &error);
 
63
                if (ctx == NULL) {
 
64
                        fprintf(stderr, gettext("Error initializing %s: %s\n"),
 
65
                                PACKAGE, lu_strerror(error));
 
66
                        return 1;
 
67
                }
 
68
                if (!lu_homedir_populate(ctx, "/etc/skel", argv[optind], 500,
 
69
                                         500, 0700, &error)) {
 
70
                        fprintf(stderr, "populate_homedir(%s) failed: %s\n",
 
71
                                argv[optind], lu_strerror(error));
 
72
                        return 1;
 
73
                }
 
74
                lu_end(ctx);
62
75
        }
63
76
        if (mod
64
77
            && !lu_homedir_move(argv[optind], argv[optind + 1], &error)) {