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

split service configuration

parent 0703ce71
No related branches found
No related tags found
No related merge requests found
......@@ -180,7 +180,7 @@ man: $(ALL_MAN:%.scd=%)
install-man:
for i in 1 5 8 ; do \
install -m755 -d $(DESTDIR)$(mandir)/man$$i; \
install -m644 man/*.$$i $(DESTDIR)$(mandir)/man$$i/ ; \
install -m644 doc/man/*.$$i $(DESTDIR)$(mandir)/man$$i/ ; \
done
.PHONY: it all clean distclean tgz strip install install-dynlib install-bin install-lib install-include man install-man
......
......@@ -9,61 +9,65 @@ Usage: $0 [OPTION]... [TARGET]
Defaults for the options are specified in brackets.
System types:
--target=TARGET configure to run on target TARGET [detected]
--host=TARGET same as --target
--target=TARGET configure to run on target TARGET [detected]
--host=TARGET same as --target
Installation directories:
--prefix=PREFIX main installation prefix [/]
--exec-prefix=EPREFIX installation prefix for executable files [PREFIX]
--prefix=PREFIX main installation prefix [/]
--exec-prefix=EPREFIX installation prefix for executable files [PREFIX]
Fine tuning of the installation directories:
--dynlibdir=DIR shared library files [PREFIX/lib]
--bindir=BINDIR user executables [EPREFIX/bin]
--libexecdir=DIR package-scoped executables [EPREFIX/libexec]
--libdir=DIR static library files [PREFIX/lib/$package]
--includedir=DIR C header files [PREFIX/include]
--sysconfdir=SYSDIR global configuration files [/etc/66]
--datarootdir=DATAROOTDIR read-only architecture-independent data root [PREFIX/share]
--mandir=DIR man documentation [$datarootdir/man]
--dynlibdir=DIR shared library files [PREFIX/lib]
--bindir=BINDIR user executables [EPREFIX/bin]
--libexecdir=DIR package-scoped executables [EPREFIX/libexec]
--libdir=DIR static library files [PREFIX/lib/$package]
--includedir=DIR C header files [PREFIX/include]
--sysconfdir=SYSDIR global configuration files [/etc/66]
--datarootdir=DATAROOTDIR read-only architecture-independent data root [PREFIX/share]
--mandir=DIR man documentation [$datarootdir/man]
--shebangdir=DIR absolute path for execline #\! invocations [BINDIR]
--livedir=DIR default live directory [/run/66]
--with-system-log=DIR system service log directory[/var/log/66]
--with-system-dir=DIR 66 tools system working directory[PREFIX/lib/66]
--with-system-service=DIR system service frontend directory[DATAROOTDIR/66/service]
--with-system-service-conf=DIR system service configuration file directory[SYSDIR/conf/system]
--with-sysadmin-service=DIR sysadmin service frontend directory[SYSDIR/service]
--with-sysadmin-service-conf=DIR sysadmin service configuration file directory[SYSDIR/conf/sysadmin]
--with-user-dir=DIR 66 tools user working directory[.66]
--with-user-log=DIR user service log directory[.66/log]
--with-user-service=DIR user service directory[.66/service]
--with-user-service-conf=DIR user service configuration directory[.66/conf]
--shebangdir=DIR absolute path for execline #\! invocations [BINDIR]
--livedir=DIR default live directory [/run/66]
--with-system-dir=DIR 66 tools root working directory[PREFIX/lib/66]
--with-packager-service=DIR packager service installation directory[DATAROOTDIR/66/service]
--with-sys-service=DIR sysadmin service directory[SYSDIR/sysadmin/service]
--with-sys-service-conf=DIR sysadmin service configuration directory[SYSDIR/conf]
--with-system-log=DIR root service log directory[/var/log/66]
--with-user-dir=DIR 66 tools user working directory[.66]
--with-user-log=DIR user service log directory[.66/log]
--with-user-service=DIR user service directory[.66/service]
--with-user-service-conf=DIR user service configuration directory[.66/conf]
Do not set an absolute path but a \$HOME relative path for --with-user-dir,
--with-user-log, --with-user-service, --with-user-service-conf. The \$HOME prefix
will be appened at the pathname automatically in function of the user.
For example , by default the final path for --with-user-dir will be \$HOME/.66.
--with-packager-service and --with-sys-service directory must be two differents path.
For example do not set --with-sys-service=/etc/66/service/sysadmin with packager service
--with-sys-service=/etc/66/service.
--with-system-service and --with-sysadmin-service directory must be two differents path.
For example do not set --with-sysadmin-service=/etc/66/service/sysadmin with system service
--with-system-service=/etc/66/service.
If no --prefix option is given, by default --with-system-dir will be /var/lib/66.
Dependencies:
--with-sysdeps=DIR use sysdeps in DIR [PREFIX/lib/skalibs/sysdeps]
--with-include=DIR add DIR to the list of searched directories for headers
--with-lib=DIR add DIR to the list of searched directories for static libraries
--with-dynlib=DIR add DIR to the list of searched directories for shared libraries
--with-sysdeps=DIR use sysdeps in DIR [PREFIX/lib/skalibs/sysdeps]
--with-include=DIR add DIR to the list of searched directories for headers
--with-lib=DIR add DIR to the list of searched directories for static libraries
--with-dynlib=DIR add DIR to the list of searched directories for shared libraries
Optional features:
--enable-shared build shared libraries [disabled]
--disable-static do not build static libraries [enabled]
--disable-allstatic do not prefer linking against static libraries [enabled]
--enable-static-libc make entirely static binaries [disabled]
--disable-all-pic do not build static libraries as PIC [enabled]
--enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled]
--enable-absolute-paths do not rely on PATH to access this package's binaries,
hardcode absolute BINDIR/foobar paths instead [disabled]
--enable-shared build shared libraries [disabled]
--disable-static do not build static libraries [enabled]
--disable-allstatic do not prefer linking against static libraries [enabled]
--enable-static-libc make entirely static binaries [disabled]
--disable-all-pic do not build static libraries as PIC [enabled]
--enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled]
--enable-absolute-paths do not rely on PATH to access this package's binaries,
hardcode absolute BINDIR/foobar paths instead [disabled]
EOF
exit 0
}
......@@ -164,14 +168,15 @@ mandir='$datarootdir/man'
shebangdir='$bindir'
livedir='/run/66'
system_dir='$prefix/lib/66'
user_dir='.66'
system_log='/var/log/66'
user_log='.66/log'
service_packager='$datarootdir/66/service'
service_sys='$sysconfdir/sysadmin/service'
service_system='$datarootdir/66/service'
service_systemconf='$sysconfdir/conf/system'
service_adm='$sysconfdir/service'
service_admconf='$sysconfdir/conf/sysadmin'
user_dir='.66'
service_user='.66/service'
service_sysconf='$sysconfdir/conf'
service_userconf='.66/conf'
user_log='.66/log'
sysdeps='$prefix/lib/skalibs/sysdeps'
manualsysdeps=false
shared=false
......@@ -208,14 +213,15 @@ for arg ; do
--shebangdir=*) shebangisdefault=false ; shebangdir=${arg#*=} ;;
--livedir=*) livedir=${arg#*=} ;;
--with-system-dir=*) system_dir=${arg#*=} ;;
--with-user-dir=*) user_dir=${arg#*=} ;;
--with-system-log=*) system_log=${arg#*=} ;;
--with-user-log=*) user_log=${arg#*=} ;;
--with-packager-service=*) service_packager=${arg#*=} ;;
--with-sys-service=*) service_sys=${arg#*=} ;;
--with-system-service=*) service_system=${arg#*=} ;;
--with-system-service-conf=*) service_systemconf=${arg#*=} ;;
--with-sysadmin-service=*) service_adm=${arg#*=} ;;
--with-sysadmin-service-conf=*) service_admconf=${arg#*=} ;;
--with-user-dir=*) user_dir=${arg#*=} ;;
--with-user-service=*) service_user=${arg#*=} ;;
--with-sys-service-conf=*) service_sysconf=${arg#*=} ;;
--with-user-service-conf=*) service_userconf=${arg#*=} ;;
--with-user-log=*) user_log=${arg#*=} ;;
--with-sysdeps=*) sysdeps=${arg#*=} manualsysdeps=true ;;
--with-include=*) var=${arg#*=} ; stripdir var ; addincpath="$addincpath -I$var" ;;
--with-lib=*) var=${arg#*=} ; stripdir var ; addlibspath="$addlibspath -L$var" ; vpaths="$vpaths $var" ;;
......@@ -252,24 +258,36 @@ if test -z "$prefix" ; then
if test "$includedir" = '$prefix/include' ; then
includedir=/usr/include
fi
if test "$datarootdir" = '$prefix/share'; then
if test "$sysdeps" = '$prefix/lib/skalibs/sysdeps' ; then
sysdeps=/usr/lib/skalibs/sysdeps
fi
if test "$datarootdir" = '$prefix/share'; then
datarootdir=/usr/share
fi
if test "$mandir" = '$datarootdir/man'; then
mandir=$datarootdir/man
if test "$system_dir" = '$prefix/lib/66' ; then
system_dir=/var/lib/66
fi
if test "$service_packager" = '$datarootdir/service' ; then
service_packager = '$datarootdir/66/service'
# if test "$mandir" = '$datarootdir/man'; then
# mandir=$datarootdir/man
# fi
# if test "$service_system" = '$datarootdir/service' ; then
# service_system = '$datarootdir/66/service'
# fi
fi
# Add /etc/66 in the default case
if test -z "$sysconfdir" ; then
if test "$service_systemconf" = '$sysconfdir/conf/system' ; then
service_systemconf = '$sysconfdir/conf/system'
fi
if test "$system_dir" = '$prefix/lib/66' ; then
system_dir=/var/lib/66
if test "$service_adm" = '$sysconfdir/service' ; then
service_adm = '$sysconfdir/service'
fi
if test "$sysdeps" = '$prefix/lib/skalibs/sysdeps' ; then
sysdeps=/usr/lib/skalibs/sysdeps
if test "$service_admconf" = '$sysconfdir/conf/sysadmin' ; then
service_admconf = '$sysconfdir/conf/sysadmin'
fi
fi
# Expand installation directories
stripdir prefix
for i in exec_prefix dynlibdir libexecdir bindir libdir includedir shebangdir sproot sysdeps system_dir; do
......@@ -279,14 +297,14 @@ for i in exec_prefix dynlibdir libexecdir bindir libdir includedir shebangdir sp
done
stripdir datarootdir
for i in service_packager mandir; do
for i in service_system mandir; do
eval tmp=\${$i}
eval $i=$tmp
stripdir $i
done
stripdir sysconfdir
for i in service_sys service_user service_sysconf; do
for i in service_systemconf service_adm service_admconf; do
eval tmp=\${$i}
eval $i=$tmp
stripdir $i
......@@ -323,7 +341,7 @@ if $slashpackage ; then
includedir=${home}/include
sysconfdir=${home}/etc/66
datarootdir=${home}/usr/share
service_packager=${home}/${datarootdir}/66/service
service_system=${home}/${datarootdir}/66/service
if $shebangisdefault ; then
shebangdir=${extbinprefix}
fi
......@@ -470,14 +488,15 @@ datarootdir := $datarootdir
mandir := $mandir
livedir := $livedir
system_dir := $system_dir
user_dir := $user_dir
system_log := $system_log
user_log := $user_log
service_packager := $service_packager
service_sys := $service_sys
service_system := $service_system
service_systemconf := $service_systemconf
service_adm := $service_adm
service_admconf := $service_admconf
user_dir := $user_dir
service_user := $service_user
service_sysconf := $service_sysconf
service_userconf := $service_userconf
user_log := $user_log
sysdeps := $sysdeps
slashpackage := $slashpackage
sproot := $sproot
......@@ -549,9 +568,10 @@ All rights reserved.*/
#define ${package_macro_name}_SYSTEM_DIR "$system_dir/"
#define ${package_macro_name}_DATA_SYSDIR "$sysconfdir/"
#define ${package_macro_name}_LOGGER_SYSDIR "$system_log/"
#define ${package_macro_name}_SERVICE_PACKDIR "$service_packager/"
#define ${package_macro_name}_SERVICE_SYSDIR "$service_sys/"
#define ${package_macro_name}_SERVICE_SYSCONFDIR "$service_sysconf/"
#define ${package_macro_name}_SERVICE_SYSDIR "$service_system/"
#define ${package_macro_name}_SERVICE_SYSCONFDIR "$service_systemconf/"
#define ${package_macro_name}_SERVICE_ADMDIR "$service_adm/"
#define ${package_macro_name}_SERVICE_ADMCONFDIR "$service_admconf/"
/** Do not use absolute path but a \$HOME relative path
* The /home/name_of_user prefix will be automatically added to the pathname */
......
......@@ -24,7 +24,7 @@ key = value # comment not valid
Empty _value_ is *not* permitted.
If _val_ begin by a *!* character:
_key=*!*value_
key=*!*value
the _key_ will be removed from the environment after the substitution.
# LIMITS
......
......@@ -764,7 +764,7 @@ int sv_args(int argc, char const *const *argv,char const *const *envp)
/** environment */
if(!OWNER)
{
if (!stralloc_cats(&env,SS_SERVICE_SYSCONFDIR)) goto err ;
if (!stralloc_cats(&env,SS_SERVICE_ADMCONFDIR)) goto err ;
if (!stralloc_0(&env)) goto err ;
}
else
......
......@@ -120,12 +120,14 @@ int sanitize_tree(stralloc *dstree, char const *base, char const *tree,uid_t own
{
if (sanitize_extra(SS_LOGGER_SYSDIR) < 0)
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_LOGGER_SYSDIR) ; return -1 ; }
if (sanitize_extra(SS_SERVICE_PACKDIR) < 0)
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_LOGGER_SYSDIR) ; return -1 ; }
if (sanitize_extra(SS_SERVICE_SYSDIR) < 0)
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_LOGGER_SYSDIR) ; return -1 ; }
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_SERVICE_SYSDIR) ; return -1 ; }
if (sanitize_extra(SS_SERVICE_SYSCONFDIR) < 0)
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_LOGGER_SYSDIR) ; return -1 ; }
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_SERVICE_SYSCONFDIR) ; return -1 ; }
if (sanitize_extra(SS_SERVICE_ADMDIR) < 0)
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_SERVICE_ADMDIR) ; return -1 ; }
if (sanitize_extra(SS_SERVICE_ADMCONFDIR) < 0)
{ VERBO3 strerr_warnwu2sys("create directory: ",SS_SERVICE_ADMCONFDIR) ; return -1 ; }
}
else
{
......
......@@ -43,4 +43,5 @@ extern int env_substitute(char const *key, char const *val,exlsn_t *info, char c
extern int env_addkv (const char *key, const char *val, exlsn_t *info) ;
extern size_t build_env(char const *src,char const *const *envp,char const **newenv, char *tmpenv) ;
extern int env_get_from_src(stralloc *modifs,char const *src) ;
extern int env_resolve_conf(stralloc *env, char const *sv,uid_t owner) ;
#endif
......@@ -139,7 +139,8 @@ struct sv_alltype_s
uint32_t hiercopy[24] ; //dir/file to copy
int signal ;//down-signal file
unsigned int pipeline ; //pos in deps
stralloc saenv ; //type diuint32, pos in saenv
stralloc saenv ;
uint32_t srconf ; //path of the environment file
} ;
#define SV_EXEC_ZERO \
......
......@@ -13,6 +13,8 @@
*/
#include <stddef.h>
#include <string.h>
#include <errno.h>
//#include <stdio.h>
#include <oblibs/string.h>
......@@ -33,6 +35,7 @@
#include <66/environ.h>
#include <66/utils.h>
#include <66/constants.h>
#include <66/config.h>
#include <execline/execline.h>
/* @Return 1 on success
......@@ -401,3 +404,34 @@ size_t build_env(char const *src,char const *const *envp,char const **newenv, ch
stralloc_free(&modifs) ;
return 0 ;
}
int env_resolve_conf(stralloc *env, char const *sv,uid_t owner)
{
int err = errno ;
size_t svlen = strlen(sv) ;
size_t len = sizeof SS_SERVICE_ADMCONFDIR - 1 ;
char e[len + svlen + 1] ;
memcpy(e,SS_SERVICE_ADMCONFDIR,len) ;
memcpy(e + len,sv,svlen) ;
e[len + svlen] = 0 ;
if (!owner)
{
errno = 0 ;
if (access(e, F_OK) < 0)
if (errno != ENOENT) return 0 ;
if (errno == ENOENT){
if (!stralloc_cats(env,SS_SERVICE_SYSCONFDIR)) return 0 ;
}
else if (!stralloc_cats(env,SS_SERVICE_ADMCONFDIR)) return 0 ;
}
else
{
if (!set_ownerhome(env,owner)) return 0 ;
if (!stralloc_cats(env,SS_SERVICE_USERCONFDIR)) return 0 ;
}
if (!stralloc_0(env)) return 0 ;
env->len-- ;
errno = err ;
return 1 ;
}
......@@ -36,6 +36,7 @@
#include <66/enum.h>
#include <66/resolve.h>
#include <66/ssexec.h>
#include <66/environ.h>
#include <s6/config.h>//S6_BINPREFIX
#include <execline/config.h>//EXECLINE_BINPREFIX
......@@ -762,19 +763,6 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in
stralloc runuser = STRALLOC_ZERO ;
stralloc execute = STRALLOC_ZERO ;
char *envdata = 0 ;
if (!owner) envdata = SS_SERVICE_SYSCONFDIR ;
else
{
if (!set_ownerhome(&home,owner))
{ VERBO3 strerr_warnwu1sys("set home directory") ; return 0 ; }
if (!stralloc_cats(&home,SS_SERVICE_USERCONFDIR)) retstralloc(111,"write_exec") ;
if (!stralloc_0(&home)) retstralloc(111,"write_exec") ;
home.len-- ;
envdata = home.s ;
}
switch (exec->build)
{
case AUTO:
......@@ -793,7 +781,8 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in
if (sv->opts[2] && (exec->build == AUTO))
{
if (!stralloc_cats(&env,SS_BINPREFIX "execl-envfile ")) retstralloc(0,"write_exec") ;
if (!stralloc_cats(&env,envdata)) retstralloc(0,"write_exec") ;
if (!env_resolve_conf(&env,name,owner))
{ VERBO3 strerr_warnwu1sys("get path of service configuration file") ; return 0 ; }
if (!stralloc_cats(&env,name)) retstralloc(0,"write_exec") ;
if (!stralloc_cats(&env,"\n")) retstralloc(0,"write_exec") ;
}
......
......@@ -118,7 +118,7 @@ int ss_resolve_src_path(stralloc *sasrc,char const *sv, ssexec_t *info)
char const *src = 0 ;
unsigned int found = 0 ;
stralloc home = STRALLOC_ZERO ;
if (!info->owner) src = SS_SERVICE_SYSDIR ;
if (!info->owner) src = SS_SERVICE_ADMDIR ;
else
{
if (!set_ownerhome(&home,info->owner)){ VERBO3 strerr_warnwu1sys("set home directory") ; goto err ; }
......@@ -133,13 +133,13 @@ int ss_resolve_src_path(stralloc *sasrc,char const *sv, ssexec_t *info)
if (!r)
{
found = 0 ;
src = SS_SERVICE_SYSDIR ;
src = SS_SERVICE_ADMDIR ;
r = ss_resolve_src(sasrc,sv,src,&found) ;
if (r < 0) { VERBO3 strerr_warnwu2sys("parse source directory: ",src) ; goto err ; }
if (!r)
{
found = 0 ;
src = SS_SERVICE_PACKDIR ;
src = SS_SERVICE_SYSDIR ;
r = ss_resolve_src(sasrc,sv,src,&found) ;
if (r < 0) { VERBO3 strerr_warnwu2sys("parse source directory: ",src) ; goto err ; }
if (!r) { VERBO3 strerr_warnw2sys("unknown service: ",sv) ; goto err ; }
......
......@@ -37,19 +37,10 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_
stralloc conf = STRALLOC_ZERO ;
stralloc var = STRALLOC_ZERO ;
stralloc salist = STRALLOC_ZERO ;
stralloc sasrc = STRALLOC_ZERO ;
char const *src = 0 , *sv = 0 ;
if (!info->owner) src = SS_SERVICE_SYSCONFDIR ;
else
{
if (!set_ownerhome(&conf,info->owner)) strerr_diefu1sys(111,"set home directory");
if (!stralloc_cats(&conf,SS_SERVICE_USERCONFDIR)) retstralloc(111,"main") ;
if (!stralloc_0(&conf)) retstralloc(111,"main") ;
conf.len-- ;
src = conf.s ;
}
char const *sv = 0, *src = 0 ;
{
subgetopt_t l = SUBGETOPT_ZERO ;
......@@ -73,6 +64,8 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_
if (argc < 1) exitusage(usage_env) ;
sv = argv[0] ;
if (!env_resolve_conf(&sasrc,sv,info->owner)) strerr_diefu1sys(111,"get path of the configuration file") ;
if (!src) src = sasrc.s ;
if (!file_readputsa(&salist,src,sv)) strerr_diefu3sys(111,"read: ",src,sv) ;
if (list)
{
......@@ -108,7 +101,7 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_
if (!stralloc_cats(&newlist,"\n")) retstralloc(111,"replace") ;
}
if (!file_write_unsafe(src,sv,newlist.s,newlist.len))
strerr_diefu4sys(111,"write: ",src,"/",sv) ;
strerr_diefu3sys(111,"write: ",src,sv) ;
stralloc_free(&newlist) ;
stralloc_free(&sa) ;
......@@ -118,6 +111,7 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_
}
freed:
stralloc_free(&conf) ;
stralloc_free(&sasrc) ;
stralloc_free(&var) ;
stralloc_free(&salist) ;
return 0 ;
......
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