diff options
author | Dan Nicholson <dbn.lists@gmail.com> | 2008-06-10 09:11:46 -0700 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2008-06-10 09:11:46 -0700 |
commit | fb295fccaf2a5d6680ad0305b929dfd1005ce49c (patch) | |
tree | 593b1151157b4f08044de8825db3d74adbc99848 | |
parent | cf1e6b512835784b8672623e524fd355e85d41df (diff) |
Only pass service basenames to the intid functions
The initd functions operate on service names rather than full paths, so
the directory names are stripped off. This is not quite correct as we
really want to just strip the init.d directory name from the beginning
of the path and leave the rest. However, it should work in practice as
only one init.d directory can be used and we expect it to be a flat
directory containing scripts.
-rw-r--r-- | src/install_initd.c | 10 | ||||
-rw-r--r-- | src/remove_initd.c | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/install_initd.c b/src/install_initd.c index e9c48bf..ecb2e15 100644 --- a/src/install_initd.c +++ b/src/install_initd.c @@ -28,6 +28,7 @@ int main(int argc, char *argv[]) { char *id_dir = NULL; initd_list_t *all, *startlist, *stoplist; + strarg_t *srvargs = strarg_new(); dep_t *need = dep_new(); /* parse arguments */ @@ -63,11 +64,14 @@ int main(int argc, char *argv[]) program_invocation_name); /* Process the services */ - while (optind < argc) - dep_add(need, argv[optind++]); + while (optind < argc) { + char *arg = argv[optind++]; + strarg_add(srvargs, arg); + dep_add(need, initd_basename(arg)); + } /* Set the initd directory from the arguments */ - if (!set_initd_dir(&id_dir, need)) + if (!set_initd_dir(&id_dir, srvargs)) exit(EXIT_FAILURE); all = initd_list_from_dir(id_dir); diff --git a/src/remove_initd.c b/src/remove_initd.c index 6b5b9ab..f6c7838 100644 --- a/src/remove_initd.c +++ b/src/remove_initd.c @@ -28,6 +28,7 @@ int main(int argc, char *argv[]) { char *id_dir = NULL; initd_list_t *all, *startlist, *stoplist; + strarg_t *srvargs = strarg_new(); dep_t *need = dep_new(); /* parse arguments */ @@ -63,11 +64,14 @@ int main(int argc, char *argv[]) program_invocation_name); /* Process the services */ - while (optind < argc) - dep_add(need, argv[optind++]); + while (optind < argc) { + char *arg = argv[optind++]; + strarg_add(srvargs, arg); + dep_add(need, initd_basename(arg)); + } /* Set the initd directory from the arguments */ - if (!set_initd_dir(&id_dir, need)) + if (!set_initd_dir(&id_dir, srvargs)) exit(EXIT_FAILURE); all = initd_list_from_dir(id_dir); |