Skip to content
Snippets Groups Projects
Commit 2d399c72 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

allow to exclude path from the research

parent 3df86eb5
No related branches found
No related tags found
No related merge requests found
...@@ -303,8 +303,8 @@ extern resolve_field_table_t resolve_service_field_table[] ; ...@@ -303,8 +303,8 @@ extern resolve_field_table_t resolve_service_field_table[] ;
extern int service_cmp_basedir(char const *dir) ; extern int service_cmp_basedir(char const *dir) ;
extern int service_endof_dir(char const *dir, char const *name) ; extern int service_endof_dir(char const *dir, char const *name) ;
extern int service_frontend_path(stralloc *sasrc,char const *sv, uid_t owner,char const *directory_forced) ; extern int service_frontend_path(stralloc *sasrc,char const *sv, uid_t owner,char const *directory_forced, char const **exclude) ;
extern int service_frontend_src(stralloc *sasrc, char const *name, char const *src) ; extern int service_frontend_src(stralloc *sasrc, char const *name, char const *src, char const **exclude) ;
extern int service_is_g(char *atree, char const *name, uint32_t flag) ; extern int service_is_g(char *atree, char const *name, uint32_t flag) ;
extern void service_resolve_array_free(resolve_service_t *ares, unsigned int areslen) ; extern void service_resolve_array_free(resolve_service_t *ares, unsigned int areslen) ;
extern int service_resolve_array_search(resolve_service_t *ares, unsigned int areslen, char const *name) ; extern int service_resolve_array_search(resolve_service_t *ares, unsigned int areslen, char const *name) ;
......
...@@ -86,6 +86,7 @@ int ssexec_parse(int argc, char const *const *argv, ssexec_t *info) ...@@ -86,6 +86,7 @@ int ssexec_parse(int argc, char const *const *argv, ssexec_t *info)
char bname[namelen + 1] ; char bname[namelen + 1] ;
char dname[namelen + 1] ; char dname[namelen + 1] ;
char const *directory_forced = 0 ; char const *directory_forced = 0 ;
char const *exclude[1] = { 0 } ;
if (argv[0][0] == '/') { if (argv[0][0] == '/') {
...@@ -102,7 +103,7 @@ int ssexec_parse(int argc, char const *const *argv, ssexec_t *info) ...@@ -102,7 +103,7 @@ int ssexec_parse(int argc, char const *const *argv, ssexec_t *info)
name_isvalid(sv) ; name_isvalid(sv) ;
if (!service_frontend_path(&sa, sv, info->owner, directory_forced)) if (!service_frontend_path(&sa, sv, info->owner, directory_forced, exclude))
log_dieu(LOG_EXIT_USER, "find service frontend file of: ", sv) ; log_dieu(LOG_EXIT_USER, "find service frontend file of: ", sv) ;
/** need to check all the contents of the stralloc. /** need to check all the contents of the stralloc.
......
...@@ -38,6 +38,8 @@ int parse_compute_list(resolve_wrapper_t_ref wres, stralloc *sa, uint32_t *res, ...@@ -38,6 +38,8 @@ int parse_compute_list(resolve_wrapper_t_ref wres, stralloc *sa, uint32_t *res,
size_t len = sa->len, pos = 0 ; size_t len = sa->len, pos = 0 ;
size_t nelement = sastr_nelement(sa) ; size_t nelement = sastr_nelement(sa) ;
stralloc tmp = STRALLOC_ZERO ; stralloc tmp = STRALLOC_ZERO ;
char const *exclude[1] = { 0 } ;
char f[len + nelement + 2] ; char f[len + nelement + 2] ;
memset(f, 0, len) ; memset(f, 0, len) ;
...@@ -51,7 +53,7 @@ int parse_compute_list(resolve_wrapper_t_ref wres, stralloc *sa, uint32_t *res, ...@@ -51,7 +53,7 @@ int parse_compute_list(resolve_wrapper_t_ref wres, stralloc *sa, uint32_t *res,
tmp.len = 0 ; tmp.len = 0 ;
r = service_frontend_path(&tmp, sa->s + pos, getuid(), 0) ; r = service_frontend_path(&tmp, sa->s + pos, getuid(), 0, exclude) ;
if (r == -1) if (r == -1)
log_dieu(LOG_EXIT_SYS, "get frontend service file of: ", sa->s + pos) ; log_dieu(LOG_EXIT_SYS, "get frontend service file of: ", sa->s + pos) ;
......
...@@ -44,6 +44,7 @@ static void parse_service_instance(stralloc *frontend, char const *svsrc, char c ...@@ -44,6 +44,7 @@ static void parse_service_instance(stralloc *frontend, char const *svsrc, char c
log_flow() ; log_flow() ;
stralloc sa = STRALLOC_ZERO ; stralloc sa = STRALLOC_ZERO ;
char const *exclude[1] = { 0 } ;
if (!instance_splitname(&sa, sv, insta, SS_INSTANCE_TEMPLATE)) if (!instance_splitname(&sa, sv, insta, SS_INSTANCE_TEMPLATE))
log_die(LOG_EXIT_SYS, "split instance service of: ", sv) ; log_die(LOG_EXIT_SYS, "split instance service of: ", sv) ;
...@@ -58,7 +59,7 @@ static void parse_service_instance(stralloc *frontend, char const *svsrc, char c ...@@ -58,7 +59,7 @@ static void parse_service_instance(stralloc *frontend, char const *svsrc, char c
/** in module the template service may not exist e.g. /** in module the template service may not exist e.g.
* module which call another module. In this case * module which call another module. In this case
* follow the classic way */ * follow the classic way */
int r = service_frontend_path(&sa, sv, getuid(), 0) ; int r = service_frontend_path(&sa, sv, getuid(), 0, exclude) ;
if (r < 1) if (r < 1)
log_dieu(LOG_EXIT_SYS, "get frontend service file of: ", sv) ; log_dieu(LOG_EXIT_SYS, "get frontend service file of: ", sv) ;
...@@ -135,7 +136,7 @@ int parse_frontend(char const *sv, resolve_service_t *ares, unsigned int *aresle ...@@ -135,7 +136,7 @@ int parse_frontend(char const *sv, resolve_service_t *ares, unsigned int *aresle
log_trace("read frontend service at: ", sv) ; log_trace("read frontend service at: ", sv) ;
if (read_svfile(&sa, svname, svsrc) <= 0) if (read_svfile(&sa, svname, svsrc) <= 0)
log_dieusys(LOG_EXIT_SYS, "read frontend service at: ", sv) ; log_dieu(LOG_EXIT_SYS, "read frontend service at: ", sv) ;
} }
char file[sa.len + 1] ; char file[sa.len + 1] ;
......
...@@ -36,6 +36,7 @@ int parse_interdependences(char const *service, char const *list, unsigned int l ...@@ -36,6 +36,7 @@ int parse_interdependences(char const *service, char const *list, unsigned int l
int r, e = 0 ; int r, e = 0 ;
size_t pos = 0, len = 0 ; size_t pos = 0, len = 0 ;
stralloc sa = STRALLOC_ZERO ; stralloc sa = STRALLOC_ZERO ;
char const *exclude[1] = { 0 } ;
if (listlen) { if (listlen) {
...@@ -73,7 +74,7 @@ int parse_interdependences(char const *service, char const *list, unsigned int l ...@@ -73,7 +74,7 @@ int parse_interdependences(char const *service, char const *list, unsigned int l
if (!strcmp(main, name)) if (!strcmp(main, name))
log_die(LOG_EXIT_USER, "direct cyclic interdependences detected -- ", main, " depends on: ", service, " which depends on: ", main) ; log_die(LOG_EXIT_USER, "direct cyclic interdependences detected -- ", main, " depends on: ", service, " which depends on: ", main) ;
r = service_frontend_path(&sa, name, getuid(), forced_directory) ; r = service_frontend_path(&sa, name, getuid(), forced_directory, exclude) ;
if (r < 1) { if (r < 1) {
log_warnu( "get frontend service file of: ", name) ; log_warnu( "get frontend service file of: ", name) ;
goto freed ; goto freed ;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <66/constants.h> #include <66/constants.h>
#include <66/service.h> #include <66/service.h>
int service_frontend_path(stralloc *sasrc, char const *sv, uid_t owner, char const *directory_forced) int service_frontend_path(stralloc *sasrc, char const *sv, uid_t owner, char const *directory_forced, char const **exclude)
{ {
log_flow() ; log_flow() ;
...@@ -34,11 +34,13 @@ int service_frontend_path(stralloc *sasrc, char const *sv, uid_t owner, char con ...@@ -34,11 +34,13 @@ int service_frontend_path(stralloc *sasrc, char const *sv, uid_t owner, char con
if (directory_forced) { if (directory_forced) {
char const *exclude[1] = { 0 } ;
if (!service_cmp_basedir(directory_forced)) if (!service_cmp_basedir(directory_forced))
log_die(LOG_EXIT_USER, "invalid base service directory: ", directory_forced) ; log_die(LOG_EXIT_USER, "invalid base service directory: ", directory_forced) ;
src = directory_forced ; src = directory_forced ;
r = service_frontend_src(sasrc, sv, src) ; r = service_frontend_src(sasrc, sv, src, exclude) ;
if (r == -1) if (r == -1)
log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ; log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ;
...@@ -59,21 +61,21 @@ int service_frontend_path(stralloc *sasrc, char const *sv, uid_t owner, char con ...@@ -59,21 +61,21 @@ int service_frontend_path(stralloc *sasrc, char const *sv, uid_t owner, char con
src = home ; src = home ;
} }
r = service_frontend_src(sasrc, sv, src) ; r = service_frontend_src(sasrc, sv, src, exclude) ;
if (r == -1) if (r == -1)
log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ; log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ;
if (!r) { if (!r) {
src = SS_SERVICE_ADMDIR ; src = SS_SERVICE_ADMDIR ;
r = service_frontend_src(sasrc, sv, src) ; r = service_frontend_src(sasrc, sv, src, exclude) ;
if (r == -1) if (r == -1)
log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ; log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ;
if (!r) { if (!r) {
src = SS_SERVICE_SYSDIR ; src = SS_SERVICE_SYSDIR ;
r = service_frontend_src(sasrc, sv, src) ; r = service_frontend_src(sasrc, sv, src, exclude) ;
if (r == -1) if (r == -1)
log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ; log_dieusys(LOG_EXIT_SYS, "parse source directory: ", src) ;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <66/service.h> #include <66/service.h>
#include <66/instance.h> #include <66/instance.h>
int service_frontend_src(stralloc *sasrc, char const *name, char const *src) int service_frontend_src(stralloc *sasrc, char const *name, char const *src, char const **exclude)
{ {
log_flow() ; log_flow() ;
...@@ -34,7 +34,6 @@ int service_frontend_src(stralloc *sasrc, char const *name, char const *src) ...@@ -34,7 +34,6 @@ int service_frontend_src(stralloc *sasrc, char const *name, char const *src)
stralloc sa = STRALLOC_ZERO ; stralloc sa = STRALLOC_ZERO ;
size_t pos = 0, dpos = 0, pathlen = strlen(src), namelen = strlen(name) ; size_t pos = 0, dpos = 0, pathlen = strlen(src), namelen = strlen(name) ;
char instaname[strlen(name) + 1] ; char instaname[strlen(name) + 1] ;
char const *exclude[1] = { 0 } ;
char path[pathlen + 1] ; char path[pathlen + 1] ;
...@@ -135,7 +134,7 @@ int service_frontend_src(stralloc *sasrc, char const *name, char const *src) ...@@ -135,7 +134,7 @@ int service_frontend_src(stralloc *sasrc, char const *name, char const *src)
dpos = 0 ; dpos = 0 ;
FOREACH_SASTR(&sa, dpos) { FOREACH_SASTR(&sa, dpos) {
r = service_frontend_src(sasrc, sa.s + dpos, dname) ; r = service_frontend_src(sasrc, sa.s + dpos, dname, exclude) ;
if (r < 0) if (r < 0)
/** system error */ /** system error */
goto err ; goto err ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment