]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-maintd: eliminate navigation in the repositories
authorBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 5 Jan 2022 08:20:09 +0000 (09:20 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Wed, 5 Jan 2022 08:20:09 +0000 (09:20 +0100)
This is not needed anymore as we use at function were possible

src/mlmmj-maintd.c

index a41b69a9d1696df6bfaac4d46b61ed92e0382212..db4754c112d0186cf78d4dd7af3041caf903ff82 100644 (file)
@@ -301,11 +301,6 @@ int resend_requeue(struct mlmmj_list *list, const char *mlmmjsend)
                log_error(LOG_ARGS, "Could not open(%s/requeue)", list->dir);
                return 1;
        }
-       if (fchdir(dirfd) < 0) {
-               log_error(LOG_ARGS, "Could not chdir(%s/requeue)", list->dir);
-               return 1;
-       }
-               
        if ((queuedir = fdopendir(dirfd)) == NULL) {
                log_error(LOG_ARGS, "Could not opendir(%s/requeue)", list->dir);
                return 1;
@@ -327,7 +322,7 @@ int resend_requeue(struct mlmmj_list *list, const char *mlmmjsend)
                /* Remove old empty directories */
                t = time(NULL);
                if(t - st.st_mtime > (time_t)3600)
-                       if(rmdir(dp->d_name) == 0)
+                       if(unlinkat(dirfd, dp->d_name, AT_REMOVEDIR) == 0)
                                continue;
 
                xasprintf(&archivefilename, "%s/archive/%s", list->dir,
@@ -426,10 +421,6 @@ int clean_nolongerbouncing(struct mlmmj_list *list)
                log_error(LOG_ARGS, "Could not open(%s/requeue)", list->dir);
                return 1;
        }
-       if (fchdir(dirfd) < 0) {
-               log_error(LOG_ARGS, "Could not chdir(%s/requeue)", list->dir);
-               return 1;
-       }
 
        if((bouncedir = fdopendir(dirfd)) == NULL) {
                log_error(LOG_ARGS, "Could not opendir(%s/requeue)", list->dir);
@@ -495,11 +486,7 @@ int probe_bouncers(struct mlmmj_list *list, const char *mlmmjbounce)
        int status;
        int dirfd = openat(list->fd, "bounce", O_DIRECTORY);
        if (dirfd == -1) {
-               log_error(LOG_ARGS, "Could not chdir(%s/bounce)", list->dir);
-               return 1;
-       }
-       if(fchdir(dirfd) < 0) {
-               log_error(LOG_ARGS, "Could not chdir(%s/bounce)", list->dir);
+               log_error(LOG_ARGS, "Could not open(%s/bounce)", list->dir);
                return 1;
        }
        if((bouncedir = fdopendir(dirfd)) == NULL) {
@@ -577,10 +564,6 @@ int unsub_bouncers(struct mlmmj_list *list)
                log_error(LOG_ARGS, "Could not chdir(%s/bounce)", list->dir);
                return 1;
        }
-       if(fchdir(dirfd) < 0) {
-               log_error(LOG_ARGS, "Could not chdir(%s/bounce)", list->dir);
-               return 1;
-       }
        if((bouncedir = fdopendir(dirfd)) == NULL) {
                log_error(LOG_ARGS, "Could not opendir(%s/bounce)", list->dir);
                return 1;
@@ -821,13 +804,6 @@ void do_maintenance(const char *listdir, const char *mlmmjsend,
                return;
        }
 
-       if(chdir(listdir) < 0) {
-               log_error(LOG_ARGS, "Could not chdir(%s). "
-                                   "No maintenance run performed.", listdir);
-               return;
-       }
-
-
        random = random_str();
        xasprintf(&logname, "maintdlog-%s", random);
        free(random);