Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
260b63d6
Commit
260b63d6
authored
5 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
chown log directory with log runner account
parent
a917a177
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/66/parser.h
+4
-18
4 additions, 18 deletions
src/include/66/parser.h
src/lib66/parser_write.c
+27
-31
27 additions, 31 deletions
src/lib66/parser_write.c
with
31 additions
and
49 deletions
src/include/66/parser.h
+
4
−
18
View file @
260b63d6
...
...
@@ -56,7 +56,7 @@ struct sv_exec_s
{
/**build=45->auto,build=46->custom*/
int
build
;
u
id_
t
runas
;
u
nsigned
in
t
runas
;
unsigned
int
shebang
;
unsigned
int
exec
;
}
;
...
...
@@ -257,14 +257,6 @@ extern int parse_service_check_enabled(ssexec_t *info, char const *svname,uint8_
extern
int
parse_service_before
(
ssexec_t
*
info
,
stralloc
*
parsed_list
,
char
const
*
sv
,
unsigned
int
*
nbsv
,
stralloc
*
sasv
,
uint8_t
force
,
uint8_t
*
exist
)
;
extern
int
parse_service_deps
(
ssexec_t
*
info
,
stralloc
*
parsed_list
,
sv_alltype
*
sv_before
,
char
const
*
sv
,
unsigned
int
*
nbsv
,
stralloc
*
sasv
,
uint8_t
force
)
;
extern
int
parse_add_service
(
stralloc
*
parsed_list
,
sv_alltype
*
sv_before
,
char
const
*
service
,
unsigned
int
*
nbsv
,
uid_t
owner
)
;
/** mill utilities
extern parse_mill_t MILL_FIRST_BRACKET ;
extern parse_mill_t MILL_GET_AROBASE_KEY ;
extern parse_mill_t MILL_GET_COMMENTED_KEY ;
extern parse_mill_t MILL_GET_SECTION_NAME ; */
/** utilities
extern int parse_line(stralloc *src,size_t *pos) ;
extern int parse_bracket(stralloc *src,size_t *pos) ; */
/** split */
extern
int
section_get_range
(
section_t
*
sasection
,
stralloc
*
src
)
;
extern
int
key_get_range
(
genalloc
*
ga
,
section_t
*
sasection
,
int
*
svtype
)
;
...
...
@@ -274,13 +266,7 @@ extern int nocheck_toservice(keynocheck *nocheck,int svtype, sv_alltype *service
extern
int
keep_common
(
sv_alltype
*
service
,
keynocheck
*
nocheck
,
int
svtype
)
;
extern
int
keep_runfinish
(
sv_exec
*
exec
,
keynocheck
*
nocheck
)
;
extern
int
keep_logger
(
sv_execlog
*
log
,
keynocheck
*
nocheck
)
;
/** helper
extern void section_setsa(int id, stralloc_ref *p,section_t *sa) ;
extern int section_get_skip(char const *s,size_t pos,int nline) ;
extern int section_get_id(stralloc *secname, char const *string,size_t *pos,int *id) ;
extern int key_get_next_id(stralloc *sa, char const *string,size_t *pos) ;
extern void parse_err(int ierr,int idsec,int idkey) ; */
extern
int
read_svfile
(
stralloc
*
sasv
,
char
const
*
name
,
char
const
*
src
)
;
/** helper */
extern
int
add_pipe
(
sv_alltype
*
sv
,
stralloc
*
sa
)
;
/** write */
extern
int
write_services
(
ssexec_t
*
info
,
sv_alltype
*
sv
,
char
const
*
workdir
,
uint8_t
force
,
uint8_t
conf
)
;
...
...
@@ -289,9 +275,9 @@ extern int write_longrun(sv_alltype *sv,char const *dst, uint8_t force, uint8_t
extern
int
write_oneshot
(
sv_alltype
*
sv
,
char
const
*
dst
,
uint8_t
conf
)
;
extern
int
write_bundle
(
sv_alltype
*
sv
,
char
const
*
dst
)
;
extern
int
write_common
(
sv_alltype
*
sv
,
char
const
*
dst
,
uint8_t
conf
)
;
extern
int
write_exec
(
sv_alltype
*
sv
,
sv_exec
*
exec
,
char
const
*
name
,
char
const
*
dst
,
in
t
mode
)
;
extern
int
write_exec
(
sv_alltype
*
sv
,
sv_exec
*
exec
,
char
const
*
name
,
char
const
*
dst
,
mode_
t
mode
)
;
extern
int
write_uint
(
char
const
*
dst
,
char
const
*
name
,
uint32_t
ui
)
;
extern
int
write_logger
(
sv_alltype
*
sv
,
sv_execlog
*
log
,
char
const
*
name
,
char
const
*
dst
,
in
t
mode
,
uint8_t
force
)
;
extern
int
write_logger
(
sv_alltype
*
sv
,
sv_execlog
*
log
,
char
const
*
name
,
char
const
*
dst
,
mode_
t
mode
,
uint8_t
force
)
;
extern
int
write_consprod
(
sv_alltype
*
sv
,
char
const
*
prodname
,
char
const
*
consname
,
char
const
*
proddst
,
char
const
*
consdst
)
;
extern
int
write_dependencies
(
unsigned
int
nga
,
unsigned
int
idga
,
char
const
*
dst
,
char
const
*
filename
)
;
extern
int
write_env
(
char
const
*
name
,
stralloc
*
sa
,
char
const
*
dst
)
;
...
...
This diff is collapsed.
Click to expand it.
src/lib66/parser_write.c
+
27
−
31
View file @
260b63d6
...
...
@@ -314,15 +314,18 @@ int write_bundle(sv_alltype *sv, char const *dst)
return
1
;
}
int
write_logger
(
sv_alltype
*
sv
,
sv_execlog
*
log
,
char
const
*
name
,
char
const
*
dst
,
in
t
mode
,
uint8_t
force
)
int
write_logger
(
sv_alltype
*
sv
,
sv_execlog
*
log
,
char
const
*
name
,
char
const
*
dst
,
mode_
t
mode
,
uint8_t
force
)
{
int
r
;
int
logbuild
=
log
->
run
.
build
;
char
*
time
=
NULL
;
char
*
pmax
=
NULL
;
char
*
pback
=
NULL
;
uid_t
log_uid
;
gid_t
log_gid
;
char
*
time
=
0
;
char
*
pmax
=
0
;
char
*
pback
=
0
;
char
*
timestamp
=
"t"
;
char
*
logrunner
=
log
->
run
.
runas
?
keep
.
s
+
log
->
run
.
runas
:
SS_LOGGER_RUNNER
;
char
max
[
UINT32_FMT
]
;
char
back
[
UINT32_FMT
]
;
char
const
*
userhome
;
...
...
@@ -416,18 +419,10 @@ int write_logger(sv_alltype *sv, sv_execlog *log,char const *name, char const *d
/** uid */
if
(
!
stralloc_cats
(
&
shebang
,
"#!"
EXECLINE_SHEBANGPREFIX
"execlineb -P
\n
"
))
retstralloc
(
0
,
"write_logger"
)
;
if
(
!
stralloc_0
(
&
shebang
))
retstralloc
(
0
,
"write_logger"
)
;
if
((
!
MYUID
))
// && log->run.runas))
if
((
!
MYUID
))
{
if
(
!
stralloc_cats
(
&
ui
,
S6_BINPREFIX
"s6-setuidgid "
))
retstralloc
(
0
,
"write_logger"
)
;
if
(
log
->
run
.
runas
)
{
if
(
!
get_namebyuid
(
log
->
run
.
runas
,
&
ui
))
{
VERBO3
strerr_warnwu1sys
(
"set owner for the logger"
)
;
return
0
;
}
}
else
if
(
!
stralloc_cats
(
&
ui
,
SS_LOGGER_RUNNER
))
retstralloc
(
0
,
"write_logger"
)
;
if
(
!
stralloc_cats
(
&
ui
,
logrunner
))
retstralloc
(
0
,
"write_logger"
)
;
}
if
(
!
stralloc_cats
(
&
ui
,
"
\n
"
))
retstralloc
(
0
,
"write_logger"
)
;
if
(
!
stralloc_0
(
&
ui
))
retstralloc
(
0
,
"write_logger"
)
;
...
...
@@ -541,7 +536,21 @@ int write_logger(sv_alltype *sv, sv_execlog *log,char const *name, char const *d
return
0
;
}
}
if
((
!
MYUID
))
{
if
(
!
youruid
(
&
log_uid
,
logrunner
)
||
!
yourgid
(
&
log_gid
,
log_uid
))
{
VERBO3
strerr_warnwu2sys
(
"get uid and gid of: "
,
logrunner
)
;
return
0
;
}
if
(
chown
(
destlog
.
s
,
log_uid
,
log_gid
)
==
-
1
)
{
VERBO3
strerr_warnwu2sys
(
"chown: "
,
destlog
.
s
)
;
return
0
;
}
}
stralloc_free
(
&
shebang
)
;
stralloc_free
(
&
ui
)
;
stralloc_free
(
&
exec
)
;
...
...
@@ -760,7 +769,7 @@ int write_common(sv_alltype *sv, char const *dst,uint8_t conf)
return
1
;
}
int
write_exec
(
sv_alltype
*
sv
,
sv_exec
*
exec
,
char
const
*
file
,
char
const
*
dst
,
in
t
mode
)
int
write_exec
(
sv_alltype
*
sv
,
sv_exec
*
exec
,
char
const
*
file
,
char
const
*
dst
,
mode_
t
mode
)
{
unsigned
int
type
=
sv
->
cname
.
itype
;
...
...
@@ -784,11 +793,7 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in
if
((
!
owner
&&
exec
->
runas
))
{
if
(
!
stralloc_cats
(
&
ui
,
S6_BINPREFIX
"s6-setuidgid "
))
retstralloc
(
0
,
"write_exec"
)
;
if
(
!
get_namebyuid
(
exec
->
runas
,
&
ui
))
{
VERBO3
strerr_warnwu1sys
(
"set owner for the execute file"
)
;
return
0
;
}
if
(
!
stralloc_cats
(
&
ui
,
keep
.
s
+
exec
->
runas
))
retstralloc
(
0
,
"write_exec"
)
;
if
(
!
stralloc_cats
(
&
ui
,
"
\n
"
))
retstralloc
(
0
,
"write_exec"
)
;
}
/** environment */
...
...
@@ -879,20 +884,13 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in
int
write_dependencies
(
unsigned
int
nga
,
unsigned
int
idga
,
char
const
*
dst
,
char
const
*
filename
)
{
stralloc
contents
=
STRALLOC_ZERO
;
//stralloc namedeps = STRALLOC_ZERO ;
size_t
id
=
idga
,
nid
=
nga
;
for
(;
nid
;
id
+=
strlen
(
deps
.
s
+
id
)
+
1
,
nid
--
)
{
if
(
!
stralloc_cats
(
&
contents
,
deps
.
s
+
id
)
||
!
stralloc_cats
(
&
contents
,
"
\n
"
))
retstralloc
(
0
,
"write_dependencies"
)
;
}
/*for (unsigned int i = 0; i < nga; i++)
{
if (!stralloc_obreplace(&namedeps,deps.s+genalloc_s(unsigned int,ga)[idga+i])) return 0 ;
if (!stralloc_cats(&contents,namedeps.s)) retstralloc(0,"write_dependencies") ;
if (!stralloc_cats(&contents,"\n"))
}*/
if
(
contents
.
len
)
{
if
(
!
file_write_unsafe
(
dst
,
filename
,
contents
.
s
,
contents
.
len
))
...
...
@@ -903,11 +901,9 @@ int write_dependencies(unsigned int nga,unsigned int idga,char const *dst,char c
}
stralloc_free
(
&
contents
)
;
//stralloc_free(&namedeps) ;
return
1
;
err:
stralloc_free
(
&
contents
)
;
//stralloc_free(&namedeps) ;
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment