if ((len = read( capfd, addr_filename_buff, 256 )) > 0) {
int file_pid;
char *p_filepid;
- close(capfd);
addr_filename_buff[len] = 0;
if ( (p_filepid = strrchr(addr_filename_buff, ':')) != NULL) {
*p_filepid = '\0';
} else {
LOG(log_info, logtype_afpd, "couldn't read data from %s", addr_filename );
}
+ if (capfd != -1)
+ close(capfd);
} else {
LOG(log_info, logtype_afpd, "%s is not a regular file", addr_filename );
}
mpath = obj->newtmp;
mp = makemacpath( vol, mpath, AFPOBJ_TMPSIZ, curdir, path->m_name );
if (!mp) {
+ close(tfd);
return AFPERR_PARAM;
}
mplen = mpath + AFPOBJ_TMPSIZ - mp;
memcpy(p, appltag, sizeof( appltag ));
cc = mpath + AFPOBJ_TMPSIZ - p;
if ( write( tfd, p, cc ) != cc ) {
+ close(tfd);
unlink( tempfile );
return( AFPERR_PARAM );
}
fprintf(dump, "\n");
fflush(dump);
+ fclose(dump);
return;
}
int setmode = (osx && *dirp->d_name == '.')?hf_mode:mode;
if (setfilmode(dirp->d_name, setmode, &st, vol->v_umask) < 0) {
+ closedir( dir );
LOG(log_error, logtype_afpd, "setdirmode: chmod %s: %s",dirp->d_name, strerror(errno) );
return -1;
}
}
LOG(log_info, logtype_atalkd, "plumbed %s%d", device, ppa );
+
+ close(fd);
}
return( 0 );
#include <atalk/logger.h>
#include <atalk/util.h>
+#include <atalk/errchk.h>
#include "db_param.h"
#include "dbif.h"
*/
static int dbif_stamp(DBD *dbd, void *buffer, int size)
{
+ EC_INIT;
struct stat st;
- int rc,cwd;
+ int cwd = -1;
if (size < 8)
- return -1;
+ EC_FAIL;
/* Remember cwd */
if ((cwd = open(".", O_RDONLY)) < 0) {
LOG(log_error, logtype_cnid, "error opening cwd: %s", strerror(errno));
- return -1;
+ EC_FAIL;
}
/* chdir to db_envhome */
if ((chdir(dbd->db_envhome)) != 0) {
LOG(log_error, logtype_cnid, "error chdiring to db_env '%s': %s", dbd->db_envhome, strerror(errno));
- return -1;
+ EC_FAIL;
}
- if ((rc = stat(dbd->db_table[DBIF_CNID].name, &st)) < 0) {
+ if (stat(dbd->db_table[DBIF_CNID].name, &st) < 0) {
LOG(log_error, logtype_cnid, "error stating database %s: %s", dbd->db_table[DBIF_CNID].name, db_strerror(errno));
- return -1;
+ EC_FAIL;
}
LOG(log_maxdebug, logtype_cnid,"stamp: %s", asctime(localtime(&st.st_ctime)));
memset(buffer, 0, size);
memcpy(buffer, &st.st_ctime, sizeof(st.st_ctime));
- if ((fchdir(cwd)) != 0) {
- LOG(log_error, logtype_cnid, "error chdiring back: %s", strerror(errno));
- return -1;
+EC_CLEANUP:
+ if (cwd != -1) {
+ if (fchdir(cwd) != 0) {
+ LOG(log_error, logtype_cnid, "error chdiring back: %s", strerror(errno));
+ EC_STATUS(-1);
+ }
+ close(cwd);
}
-
- return 0;
+ EC_EXIT;
}
/*!
}
pwd->pw_passwd = sp->sp_pwdp;
- if (sp && sp->sp_max != -1 && sp->sp_lstchg) {
+ if (sp->sp_max != -1 && sp->sp_lstchg) {
time_t now = time(NULL) / (60*60*24);
int32_t expire_days = sp->sp_lstchg - now + sp->sp_max;
if ( expire_days < 0 ) {
}
pwd->pw_passwd = sp->sp_pwdp;
- if (sp && sp->sp_max != -1 && sp->sp_lstchg) {
+ if (sp->sp_max != -1 && sp->sp_lstchg) {
time_t now = time(NULL) / (60*60*24);
int32_t expire_days = sp->sp_lstchg - now + sp->sp_max;
if ( expire_days < 0 ) {