~ubuntu-branches/debian/sid/netatalk/sid

« back to all changes in this revision

Viewing changes to etc/cnid_dbd/dbif.c

  • Committer: Package Import Robot
  • Author(s): Jonas Smedegaard
  • Date: 2012-03-20 23:37:08 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120320233708-sp2k0av7f9sjnf4w
Tags: 2.2.2-1
* New upstream release.
* Drop patch cherry-picked upstream: Included in new upstream release.
* Build-depend on libldap2-dev and libacl1-dev, to enable LDAP support
  and support for extended ACLs (and possibly avoid FTBFS).
  Closes: bug#645290, #651406. Thanks to Peter Eisentraut and masc.
* Update copyright file:
  + Bump format to 1.0.
  + Fix double-indent in Copyright fields as per Policy §5.6.13.
  + Add Files paragraph for ACL code.
* Bump standards-version to 3.9.3.
* Update copyright file: Add disclaimer to License paragraph
  GAP~Makefile.in.
* Bump debhelper compat level to 7.
* Add patch 101 to start avahi-daemon (if available) before atalkd.
  Recommend avahi-daemon.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include <atalk/logger.h>
23
23
#include <atalk/util.h>
 
24
#include <atalk/errchk.h>
24
25
 
25
26
#include "db_param.h"
26
27
#include "dbif.h"
33
34
 */
34
35
static int dbif_stamp(DBD *dbd, void *buffer, int size)
35
36
{
 
37
    EC_INIT;
36
38
    struct stat st;
37
 
    int         rc,cwd;
 
39
    int cwd = -1;
38
40
 
39
41
    if (size < 8)
40
 
        return -1;
 
42
        EC_FAIL;
41
43
 
42
44
    /* Remember cwd */
43
45
    if ((cwd = open(".", O_RDONLY)) < 0) {
44
46
        LOG(log_error, logtype_cnid, "error opening cwd: %s", strerror(errno));
45
 
        return -1;
 
47
        EC_FAIL;
46
48
    }
47
49
 
48
50
    /* chdir to db_envhome */
49
51
    if ((chdir(dbd->db_envhome)) != 0) {
50
52
        LOG(log_error, logtype_cnid, "error chdiring to db_env '%s': %s", dbd->db_envhome, strerror(errno));        
51
 
        return -1;
 
53
        EC_FAIL;
52
54
    }
53
55
 
54
 
    if ((rc = stat(dbd->db_table[DBIF_CNID].name, &st)) < 0) {
 
56
    if (stat(dbd->db_table[DBIF_CNID].name, &st) < 0) {
55
57
        LOG(log_error, logtype_cnid, "error stating database %s: %s", dbd->db_table[DBIF_CNID].name, db_strerror(errno));
56
 
        return -1;
 
58
        EC_FAIL;
57
59
    }
58
60
 
59
61
    LOG(log_maxdebug, logtype_cnid,"stamp: %s", asctime(localtime(&st.st_ctime)));
61
63
    memset(buffer, 0, size);
62
64
    memcpy(buffer, &st.st_ctime, sizeof(st.st_ctime));
63
65
 
64
 
    if ((fchdir(cwd)) != 0) {
65
 
        LOG(log_error, logtype_cnid, "error chdiring back: %s", strerror(errno));        
66
 
        return -1;
 
66
EC_CLEANUP:
 
67
    if (cwd != -1) {
 
68
        if (fchdir(cwd) != 0) {
 
69
            LOG(log_error, logtype_cnid, "error chdiring back: %s", strerror(errno));        
 
70
            EC_STATUS(-1);
 
71
        }
 
72
        close(cwd);
67
73
    }
68
 
 
69
 
    return 0;
 
74
    EC_EXIT;
70
75
}
71
76
 
72
77
/*!