Welcome to little lamb

Code » anopa » commit 5819ddf

start/stop: Don't need root for --dry-list

author Olivier Brunel
2015-08-15 17:36:37 UTC
committer Olivier Brunel
2015-08-15 17:36:37 UTC
parent 7e9be13562c37071d50845b21645897229649319

start/stop: Don't need root for --dry-list

That is, init repo in READ mode when --dry-list is used, so it can be
done as a user with only read access, since we don't do anything.

src/anopa/aa-start.c +1 -1
src/anopa/aa-stop.c +1 -1

diff --git a/src/anopa/aa-start.c b/src/anopa/aa-start.c
index 5d485f1..611d506 100644
--- a/src/anopa/aa-start.c
+++ b/src/anopa/aa-start.c
@@ -307,7 +307,7 @@ main (int argc, char * const argv[])
     if (!path_list && argc < 1)
         dieusage (1);
 
-    if (aa_init_repo (path_repo, AA_REPO_WRITE) < 0)
+    if (aa_init_repo (path_repo, (mode & AA_MODE_IS_DRY) ? AA_REPO_READ : AA_REPO_WRITE) < 0)
         aa_strerr_diefu2sys (ERR_IO, "init repository ", path_repo);
 
     if (path_list)
diff --git a/src/anopa/aa-stop.c b/src/anopa/aa-stop.c
index 268bc6f..a3330ea 100644
--- a/src/anopa/aa-stop.c
+++ b/src/anopa/aa-stop.c
@@ -323,7 +323,7 @@ main (int argc, char * const argv[])
             || (!(mode & AA_MODE_STOP_ALL) && !path_list && argc < 1))
         dieusage (1);
 
-    if (aa_init_repo (path_repo, AA_REPO_WRITE) < 0)
+    if (aa_init_repo (path_repo, (mode & AA_MODE_IS_DRY) ? AA_REPO_READ : AA_REPO_WRITE) < 0)
         aa_strerr_diefu2sys (ERR_IO, "init repository ", path_repo);
 
     /* let's "preload" every services from the repo. This will have everything