~ubuntu-branches/debian/wheezy/netatalk/wheezy

« back to all changes in this revision

Viewing changes to etc/cnid_dbd/cmd_dbd.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2011-06-05 21:04:21 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110605210421-19gag2srevj0ocxh
Tags: 2.2~beta4-1
* New upstream release.
  + Fixes "Internal Error" after ad_open on sparc.
    Closes: bug#606005. Thanks to Alfredo Sola.
* Adjust references to unofficial packages in README.Debian.
* Use dversionmangle (not uversionmangle) in watch file. Fix add
  leading dash (-) to upstream version in mangling.
* Update patches:
  + Drop patches 107 and 294 (Zeroconf support): Implemented
    (differently) upstream now.
  + Drop patches 109 and 112 (avoid broken XFS linkage) obsolete.
  + Drop patch 200 (hostname resolving): adopted upstream.
  + Refresh patch 205.
* Rewrite copyright file using draft 174 of DEP-5 format.
* Build-depend on and recommend unversioned (i.e. default) BerkeleyDB
  packages.
  Closes: bug#621413. Thanks to Ondřej Surý.
  Simplify suggestions on older versioned BerkeleyDB packages.
* Stop installing some documentation dropped upstream, and let CDBS
  automagically handle some of the remains.
* Update control file:
  + Bump policy compliance to standards-version 3.9.2.
  + Shorten Vcs-* URLs.
* Add patches 115 and (for automade file) 214 to avoid installing
  unneeded /default dir.
  Closes: bug#628119. Thanks to Russell Muetzelfeldt and Luk Claes.
* Don't ship .la files. Closes: bug#621849. Thanks to Andreas Metzler
  and Luk Claes.
* Stop renaming afile and achfile, dropped upstream.
* Explicitly enable DDP (AppleTalk), now disabled by default.
* Enable Zeroconf, should be stable now.
* Simplify package relations:
  + Drop (build-)dependency fallback unneeded even for oldstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* 
2
 
   $Id: cmd_dbd.c,v 1.26 2010-04-20 16:46:20 hat001 Exp $
3
 
 
4
2
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
5
3
   
6
4
   This program is free software; you can redistribute it and/or modify
84
82
 
85
83
int nocniddb = 0;               /* Dont open CNID database, only scan filesystem */
86
84
volatile sig_atomic_t alarmed;
 
85
struct volinfo volinfo; /* needed by pack.c:idxname() */
87
86
 
88
87
static DBD *dbd;
89
88
static int verbose;             /* Logging flag */
91
90
static struct db_param db_param = {
92
91
    NULL,                       /* Volume dirpath */
93
92
    1,                          /* bdb logfile autoremove */
94
 
    64 * 1024,                  /* bdb cachesize (64 MB) */
 
93
    256 * 1024,                  /* bdb cachesize (256 MB) */
 
94
    5000,                       /* maxlocks */
 
95
    5000,                       /* maxlockobjs */
95
96
    -1,                         /* not used ... */
96
97
    -1,
97
98
    "",
99
100
    -1,
100
101
    -1
101
102
};
102
 
static char dbpath[PATH_MAX];   /* Path to the dbd database */
 
103
static char dbpath[MAXPATHLEN+1];   /* Path to the dbd database */
103
104
 
104
105
/* 
105
106
   Provide some logging
279
280
    int dump=0, scan=0, rebuild=0, prep_upgrade=0, rebuildindexes=0, dumpindexes=0, force=0;
280
281
    dbd_flags_t flags = 0;
281
282
    char *volpath;
282
 
    struct volinfo volinfo;
283
283
    int cdir;
284
284
 
285
285
    if (geteuid() != 0) {
380
380
        exit(EXIT_FAILURE);        
381
381
    }
382
382
 
 
383
    /* Enuser dbpath is there, create if necessary */
 
384
    struct stat st;
 
385
    if (stat(volinfo.v_dbpath, &st) != 0) {
 
386
        if (errno != ENOENT) {
 
387
            dbd_log( LOGSTD, "Can't stat dbpath \"%s\": %s", volinfo.v_dbpath, strerror(errno));
 
388
            exit(EXIT_FAILURE);        
 
389
        }
 
390
        if ((mkdir(volinfo.v_dbpath, 0755)) != 0) {
 
391
            dbd_log( LOGSTD, "Can't create dbpath \"%s\": %s", dbpath, strerror(errno));
 
392
            exit(EXIT_FAILURE);
 
393
        }        
 
394
    }
 
395
 
383
396
    /* Put "/.AppleDB" at end of volpath, get path from volinfo file */
384
 
    if ( (strlen(volinfo.v_dbpath) + strlen("/.AppleDB")) > (PATH_MAX - 1) ) {
 
397
    if ( (strlen(volinfo.v_dbpath) + strlen("/.AppleDB")) > MAXPATHLEN ) {
385
398
        dbd_log( LOGSTD, "Volume pathname too long");
386
399
        exit(EXIT_FAILURE);        
387
400
    }
388
 
    strncpy(dbpath, volinfo.v_dbpath, PATH_MAX - 9 - 1);
 
401
    strncpy(dbpath, volinfo.v_dbpath, MAXPATHLEN - strlen("/.AppleDB"));
389
402
    strcat(dbpath, "/.AppleDB");
390
403
 
391
404
    /* Check or create dbpath */
412
425
 
413
426
    /* Prepare upgrade ? */
414
427
    if (prep_upgrade) {
415
 
        if (dbif_prep_upgrade(dbpath))
 
428
        if (dbif_env_remove(dbpath))
416
429
            goto exit_failure;
417
430
        goto exit_success;
418
431
    }        
420
433
    /* Check if -f is requested and wipe db if yes */
421
434
    if ((flags & DBD_FLAGS_FORCE) && rebuild && (volinfo.v_flags & AFPVOL_CACHE)) {
422
435
        char cmd[8 + MAXPATHLEN];
423
 
        snprintf(cmd, 8 + MAXPATHLEN, "rm -f %s/*", dbpath);
 
436
        snprintf(cmd, 8 + MAXPATHLEN, "rm -rf \"%s\"", dbpath);
424
437
        dbd_log( LOGDEBUG, "Removing old database of volume: '%s'", volpath);
425
438
        system(cmd);
 
439
        if ((mkdir(dbpath, 0755)) != 0) {
 
440
            dbd_log( LOGSTD, "Can't create dbpath \"%s\": %s", dbpath, strerror(errno));
 
441
            exit(EXIT_FAILURE);
 
442
        }
426
443
        dbd_log( LOGDEBUG, "Removed old database.");
427
444
    }
428
445
 
445
462
            dbif_close(dbd);
446
463
            goto exit_failure;
447
464
        }
448
 
 
449
 
        if (dbd_stamp(dbd) < 0) {
450
 
            dbif_close(dbd);
451
 
            goto exit_failure;
452
 
        }
453
465
    }
454
466
 
455
467
    /* Now execute given command scan|rebuild|dump */