diff options
| -rw-r--r-- | src/authdb.c | 19 | 
1 files changed, 16 insertions, 3 deletions
diff --git a/src/authdb.c b/src/authdb.c index a329d8b..c9a5dd3 100644 --- a/src/authdb.c +++ b/src/authdb.c @@ -8,12 +8,15 @@  #include <ctype.h>  #include <time.h>  #include <grp.h> +#include <errno.h> +#include <string.h>  #include "config.h"  #include "authdb.h"  #include "filterdb.h"  #include "addr.h"  #include "blob.h" +#include "reporting.h"  #define ALIGN(s,a)		(((s) + a - 1) & ~(a - 1)) @@ -38,17 +41,22 @@ static struct authdb_map_entry *authdb_me_open(sockaddr_any *addr, int create)  		oflag |= O_CREAT;  	fd = shm_open(name, oflag, 0660); -	if (fd < 0) +	if (fd < 0) { +		report_error("Couldn't create shared memory object. Error: %s\n", strerror(errno));  		return NULL; +	}  	if (ftruncate(fd, AUTHDB_SHM_SIZE) < 0) {  		close(fd); +		report_error("Couldn't truncate shared memory object. Error: %s\n", strerror(errno));  		return NULL;  	}  	getgrnam_r("squark", &grp, buf, sizeof(buf), &res);  	if (res != NULL) { -		fchown(fd, -1, res->gr_gid); +		if (fchown(fd, -1, res->gr_gid) < 0) +			report_error("Couldn't set group ownership of shared memory object. Error: %s\n", +				strerror(errno));  		fchmod(fd, 0660);  	} @@ -56,12 +64,17 @@ static struct authdb_map_entry *authdb_me_open(sockaddr_any *addr, int create)  		    PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);  	close(fd); -	if (base == MAP_FAILED) +	if (base == MAP_FAILED) { +		report_error("Couldn't map shared memory object into address space. Error: %s\n", +			strerror(errno));  		return NULL; +	}  	me = malloc(sizeof(*me));  	if (me == NULL) {  		munmap(base, AUTHDB_SHM_SIZE); +		report_error("Couldn't allocate memory for authentication database entry. Error: %s\n", +			strerror(errno));  		return NULL;  	}  | 
