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
c9c44b9f
Commit
c9c44b9f
authored
11 months ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
Do not crash if service doesn't exist
in case of resolve file corruption. Use of lexer functions.
parent
f845397b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib66/exec/ssexec_tree_admin.c
+34
-27
34 additions, 27 deletions
src/lib66/exec/ssexec_tree_admin.c
with
34 additions
and
27 deletions
src/lib66/exec/ssexec_tree_admin.c
+
34
−
27
View file @
c9c44b9f
...
...
@@ -28,6 +28,8 @@
#include
<oblibs/string.h>
#include
<oblibs/sastr.h>
#include
<oblibs/graph.h>
#include
<oblibs/lexer.h>
#include
<oblibs/stack.h>
#include
<skalibs/sgetopt.h>
#include
<skalibs/stralloc.h>
...
...
@@ -186,18 +188,19 @@ void tree_parse_uid_list(uid_t *uids, char const *str)
log_flow
()
;
size_t
pos
=
0
;
stralloc
sa
=
STRALLOC_ZERO
;
if
(
!
sastr_clean_string_wdelim
(
&
sa
,
str
,
TREE_COMMA_DELIM
))
log_dieu
(
LOG_EXIT_SYS
,
"parse uid list"
)
;
_alloc_stk_
(
stk
,
strlen
(
str
)
+
1
)
;
if
(
!
lexer_trim_with_delim
(
&
stk
,
str
,
TREE_COMMA_DELIM
))
log_dieu
(
LOG_EXIT_SYS
,
"parse options"
)
;
uid_t
owner
=
getuid
()
;
/** special case, we don't know which user want to use
* the tree, we need a general name to allow all users.
* The term "user" is took here to allow the current user*/
ssize_t
p
=
s
astr_cmp
(
&
s
a
,
"user"
)
;
ssize_t
p
=
s
tack_retrieve_element
(
&
s
tk
,
"user"
)
;
FOREACH_S
ASTR
(
&
s
a
,
pos
)
{
FOREACH_S
TK
(
&
s
tk
,
pos
)
{
if
(
pos
==
(
size_t
)
p
)
{
...
...
@@ -215,12 +218,9 @@ void tree_parse_uid_list(uid_t *uids, char const *str)
continue
;
}
if
(
!
scan_uidlist
(
sa
.
s
+
pos
,
uids
))
log_dieu
(
LOG_EXIT_USER
,
"scan account: "
,
sa
.
s
+
pos
)
;
if
(
!
scan_uidlist
(
stk
.
s
+
pos
,
uids
))
log_dieu
(
LOG_EXIT_USER
,
"scan account: "
,
stk
.
s
+
pos
)
;
}
stralloc_free
(
&
sa
)
;
}
static
void
tree_parse_options_depends
(
graph_t
*
g
,
ssexec_t
*
info
,
char
const
*
str
,
uint8_t
requiredby
,
tree_what_t
*
what
)
...
...
@@ -233,24 +233,23 @@ static void tree_parse_options_depends(graph_t *g, ssexec_t *info, char const *s
int
r
;
size_t
pos
=
0
;
char
*
name
=
0
;
str
alloc
sa
=
STRALLOC_ZERO
;
_
alloc
_stk_
(
stk
,
strlen
(
str
)
+
1
)
;
if
(
!
sastr_clean_string_w
delim
(
&
s
a
,
str
,
TREE_COMMA_DELIM
))
if
(
!
lexer_trim_with_
delim
(
&
s
tk
,
str
,
TREE_COMMA_DELIM
))
log_dieu
(
LOG_EXIT_SYS
,
"clean sub options"
)
;
if
(
s
astr_cmp
(
&
s
a
,
"none"
)
>=
0
)
{
if
(
s
tack_retrieve_element
(
&
s
tk
,
"none"
)
>=
0
)
{
if
(
!
requiredby
)
what
->
ndepends
=
0
;
else
what
->
nrequiredby
=
0
;
stralloc_free
(
&
sa
)
;
return
;
}
FOREACH_S
ASTR
(
&
s
a
,
pos
)
{
FOREACH_S
TK
(
&
s
tk
,
pos
)
{
name
=
s
a
.
s
+
pos
;
name
=
s
tk
.
s
+
pos
;
r
=
tree_isvalid
(
info
->
base
.
s
,
name
)
;
if
(
r
<
0
)
...
...
@@ -312,8 +311,6 @@ static void tree_parse_options_depends(graph_t *g, ssexec_t *info, char const *s
log_die
(
LOG_EXIT_SYS
,
"add requiredby: "
,
name
,
" to: "
,
info
->
treename
.
s
)
;
}
}
stralloc_free
(
&
sa
)
;
}
static
void
tree_parse_options
(
graph_t
*
g
,
char
const
*
str
,
ssexec_t
*
info
,
tree_what_t
*
what
)
...
...
@@ -326,19 +323,19 @@ static void tree_parse_options(graph_t *g, char const *str, ssexec_t *info, tree
size_t
pos
=
0
,
len
=
0
;
ssize_t
r
;
char
*
line
=
0
,
*
key
=
0
,
*
val
=
0
;
str
alloc
sa
=
STRALLOC_ZERO
;
_
alloc
_stk_
(
stk
,
strlen
(
str
)
+
1
)
;
tree_opts_map_t
const
*
t
;
if
(
!
sastr_clean_string_w
delim
(
&
s
a
,
str
,
TREE_COLON_DELIM
))
if
(
!
lexer_trim_with_
delim
(
&
s
tk
,
str
,
TREE_COLON_DELIM
))
log_dieu
(
LOG_EXIT_SYS
,
"clean options"
)
;
unsigned
int
n
=
sastr_len
(
&
sa
),
nopts
=
0
,
old
;
unsigned
int
nopts
=
0
,
old
;
tree_checkopts
(
n
)
;
tree_checkopts
(
stk
.
count
)
;
FOREACH_S
ASTR
(
&
s
a
,
pos
)
{
FOREACH_S
TK
(
&
s
tk
,
pos
)
{
line
=
s
a
.
s
+
pos
;
line
=
s
tk
.
s
+
pos
;
t
=
tree_opts_table
;
old
=
nopts
;
...
...
@@ -421,8 +418,6 @@ static void tree_parse_options(graph_t *g, char const *str, ssexec_t *info, tree
if
(
old
==
nopts
)
log_die
(
LOG_EXIT_SYS
,
"invalid option: "
,
line
)
;
}
stralloc_free
(
&
sa
)
;
}
void
tree_parse_seed
(
char
const
*
treename
,
tree_seed_t
*
seed
,
tree_what_t
*
what
)
...
...
@@ -908,7 +903,7 @@ static void tree_service_switch_contents(char const *base, char const *treesrc,
{
log_flow
()
;
size_t
pos
=
0
;
size_t
pos
=
0
;
ssize_t
r
=
-
1
;
resolve_tree_t
tres
=
RESOLVE_TREE_ZERO
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_TREE
,
&
tres
)
;
resolve_service_t
res
=
RESOLVE_SERVICE_ZERO
;
...
...
@@ -921,6 +916,18 @@ static void tree_service_switch_contents(char const *base, char const *treesrc,
FOREACH_SASTR
(
&
sa
,
pos
)
{
log_trace
(
"switch service: "
,
sa
.
s
+
pos
,
" to tree: "
,
treedst
)
;
/** Tree may be corrupted, check the validity of the service
* before switching it. It also avoid to crash the process
* for an unexisting service which can cause a stuck situation where
* you cannot remove a tree for a corrupted list of service.*/
r
=
resolve_read_g
(
swres
,
base
,
sa
.
s
+
pos
)
;
if
(
r
==
-
1
)
log_dieusys
(
LOG_EXIT_SYS
,
"get information of service: "
,
sa
.
s
+
pos
,
" -- please make a bug report"
)
;
if
(
!
r
)
continue
;
tree_service_add
(
treedst
,
sa
.
s
+
pos
,
info
)
;
if
(
!
resolve_modify_field_g
(
swres
,
base
,
sa
.
s
+
pos
,
E_RESOLVE_SERVICE_TREENAME
,
treedst
))
...
...
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