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
865c9403
Commit
865c9403
authored
6 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
fix non root directory
parent
a8cc80c2
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/lib66/parser.c
+17
-8
17 additions, 8 deletions
src/lib66/parser.c
src/lib66/parser_write.c
+30
-7
30 additions, 7 deletions
src/lib66/parser_write.c
with
47 additions
and
15 deletions
src/lib66/parser.c
+
17
−
8
View file @
865c9403
...
...
@@ -104,11 +104,11 @@ static int read_svfile(stralloc *sasv,char const *name,char const *src)
size_t
srclen
=
strlen
(
src
)
;
size_t
namelen
=
strlen
(
name
)
;
char
svtmp
[
srclen
+
namelen
+
1
]
;
char
svtmp
[
srclen
+
1
+
namelen
+
1
]
;
memcpy
(
svtmp
,
src
,
srclen
)
;
svtmp
[
srclen
]
=
'/'
;
memcpy
(
svtmp
+
srclen
+
1
,
name
,
namelen
)
;
svtmp
[
srclen
+
namelen
+
1
]
=
0
;
svtmp
[
srclen
+
1
+
namelen
]
=
0
;
VERBO3
strerr_warni4x
(
"Read service file of : "
,
name
,
" at: "
,
src
)
;
...
...
@@ -270,7 +270,7 @@ static int start_parser(stralloc *sasv,char const *name,sv_alltype *sv_before)
stralloc_free
(
sasv
)
;
return
0
;
}
static
int
deps_src
(
stralloc
*
newsrc
,
char
const
*
src
,
char
const
*
name
,
char
const
*
tree
,
unsigned
int
force
)
static
int
deps_src
(
stralloc
*
newsrc
,
char
const
*
name
,
char
const
*
tree
,
unsigned
int
force
)
{
int
r
,
err
;
uint32_t
avlid
;
...
...
@@ -283,11 +283,16 @@ static int deps_src(stralloc *newsrc,char const *src, char const *name, char con
genalloc
tmpsrc
=
GENALLOC_ZERO
;
//type diuint32
stralloc
sa
=
STRALLOC_ZERO
;
stralloc
home
=
STRALLOC_ZERO
;
*
newsrc
=
stralloc_zero
;
err
=
1
;
if
(
!
owner
)
src
=
SS_SERVICE_SYSDIR
;
else
src
=
SS_SERVICE_USERDIR
;
if
(
!
set_ownerhome
(
&
home
,
owner
))
{
VERBO3
strerr_warnwu1sys
(
"set home directory"
)
;
err
=
0
;
goto
end
;
}
if
(
!
stralloc_cats
(
newsrc
,
tree
))
retstralloc
(
0
,
"deps_src"
)
;
if
(
!
stralloc_cats
(
newsrc
,
SS_SVDIRS
))
retstralloc
(
0
,
"deps_src"
)
;
...
...
@@ -306,8 +311,12 @@ static int deps_src(stralloc *newsrc,char const *src, char const *name, char con
if
(
!
owner
)
{
if
(
!
stralloc_obreplace
(
newsrc
,
SS_SERVICE_SYSDIR
))
retstralloc
(
0
,
"deps_src"
)
;
}
else
if
(
!
stralloc_obreplace
(
newsrc
,
SS_SERVICE_USERDIR
))
retstralloc
(
0
,
"deps_src"
)
;
}
else
{
if
(
!
stralloc_cats
(
&
home
,
SS_SERVICE_USERDIR
))
retstralloc
(
0
,
"deps_src"
)
;
if
(
!
stralloc_obreplace
(
newsrc
,
home
.
s
))
retstralloc
(
0
,
"deps_src"
)
;
}
if
(
!
resolve_src
(
&
tmpsrc
,
&
sa
,
name
,
newsrc
->
s
,
&
found
))
{
...
...
@@ -426,7 +435,7 @@ int resolve_srcdeps(sv_alltype *sv_before,char const *mainsv, char const *src, c
return
0
;
}
}
r
=
deps_src
(
&
newsrc
,
src
,
dname
.
s
,
tree
,
force
)
;
r
=
deps_src
(
&
newsrc
,
dname
.
s
,
tree
,
force
)
;
if
(
!
r
)
return
0
;
if
(
insta
>
0
)
{
...
...
This diff is collapsed.
Click to expand it.
src/lib66/parser_write.c
+
30
−
7
View file @
865c9403
...
...
@@ -753,8 +753,18 @@ int write_common(sv_alltype *sv, char const *dst)
if
(
sv
->
opts
[
2
])
{
char
*
dst
=
0
;
if
(
!
MYUID
)
dst
=
SS_SERVICE_SYSCONFDIR
;
else
dst
=
SS_SERVICE_USERCONFDIR
;
uid_t
owner
=
MYUID
;
stralloc
home
=
STRALLOC_ZERO
;
if
(
!
owner
)
dst
=
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_common"
)
;
if
(
!
stralloc_0
(
&
home
))
retstralloc
(
111
,
"write_common"
)
;
home
.
len
--
;
dst
=
home
.
s
;
}
char
*
name
=
keep
.
s
+
sv
->
cname
.
name
;
...
...
@@ -775,7 +785,10 @@ int write_common(sv_alltype *sv, char const *dst)
VERBO3
strerr_warnwu1x
(
"write environment"
)
;
return
0
;
}
stralloc_free
(
&
home
)
;
}
return
1
;
}
...
...
@@ -785,11 +798,12 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in
unsigned
int
type
=
sv
->
cname
.
itype
;
char
*
name
=
keep
.
s
+
sv
->
cname
.
name
;
uid_t
owner
=
MYUID
;
size_t
filelen
=
strlen
(
file
)
;
size_t
dstlen
=
strlen
(
dst
)
;
char
write
[
dstlen
+
1
+
filelen
+
1
]
;
stralloc
home
=
STRALLOC_ZERO
;
stralloc
shebang
=
STRALLOC_ZERO
;
stralloc
ui
=
STRALLOC_ZERO
;
stralloc
env
=
STRALLOC_ZERO
;
...
...
@@ -797,14 +811,22 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in
stralloc
execute
=
STRALLOC_ZERO
;
char
*
envdata
=
0
;
if
(
!
MYUID
)
envdata
=
SS_SERVICE_SYSCONFDIR
;
else
envdata
=
SS_SERVICE_USERCONFDIR
;
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
:
/** uid */
if
((
!
MYUID
&&
exec
->
runas
))
if
((
!
owner
&&
exec
->
runas
))
{
if
(
!
stralloc_cats
(
&
ui
,
S6_BINPREFIX
"s6-setuidgid "
))
retstralloc
(
0
,
"write_exec"
)
;
if
(
!
get_namebyuid
(
exec
->
runas
,
&
ui
))
...
...
@@ -888,6 +910,7 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in
return
0
;
}
stralloc_free
(
&
home
)
;
stralloc_free
(
&
shebang
)
;
stralloc_free
(
&
ui
)
;
stralloc_free
(
&
execute
)
;
...
...
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