static void subscribe_type(struct mlmmj_list *list,
char *address, char *mlmmjsend,
enum subtype typesub, enum subreason reasonsub) {
- char chstr[2], *subdir;
+ char chstr[2];
+ const char *subdir;
char *sublockname = NULL;
int groupwritable = 0, sublockfd, subfilefd;
struct stat st;
int subdirfd = -1;
- switch(typesub) {
- default:
- case SUB_NORMAL:
- subdir = "subscribers.d";
- break;
- case SUB_DIGEST:
- subdir = "digesters.d";
- break;
- case SUB_NOMAIL:
- subdir = "nomailsubs.d";
- break;
- }
-
- subdirfd = openat(list->fd, subdir, O_DIRECTORY|O_CLOEXEC);
- if (subdirfd == -1)
- err(EXIT_FAILURE, "Unable to open %s/%s", list->dir, subdir);
-
+ subdirfd = open_subscriber_directory(list, typesub, &subdir);
if (fstat(subdirfd, &st) == 0) {
if(st.st_mode & S_IWGRP) {
groupwritable = S_IRGRP|S_IWGRP;
subfilefd = openat(subdirfd, chstr, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
if (subfilefd == -1) {
- log_error(LOG_ARGS, "Error opening %s/%s/%s", list->dir, subdir, chstr);
+ log_error(LOG_ARGS, "Error the siubopening %s/%s/%s", list->dir, subdir, chstr);
err(EXIT_FAILURE, "Error opening %s/%s/%s");
}