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
9881a774
Commit
9881a774
authored
2 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
fix permissions with -o options
parent
b65925bd
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_scandir_create.c
+52
-7
52 additions, 7 deletions
src/lib66/exec/ssexec_scandir_create.c
with
52 additions
and
7 deletions
src/lib66/exec/ssexec_scandir_create.c
+
52
−
7
View file @
9881a774
...
@@ -83,6 +83,20 @@ static void inline auto_dir(char const *str,mode_t mode)
...
@@ -83,6 +83,20 @@ static void inline auto_dir(char const *str,mode_t mode)
log_trace
(
"create directory: "
,
str
)
;
log_trace
(
"create directory: "
,
str
)
;
if
(
!
dir_create_parent
(
str
,
mode
))
if
(
!
dir_create_parent
(
str
,
mode
))
log_dieusys
(
LOG_EXIT_SYS
,
"create directory: "
,
str
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"create directory: "
,
str
)
;
size_t
n
=
strlen
(
str
),
i
=
0
;
char
tmp
[
n
+
1
]
;
for
(;
i
<
n
;
i
++
)
{
if
((
str
[
i
]
==
'/'
)
&&
i
)
{
tmp
[
i
]
=
0
;
auto_chown
(
tmp
)
;
}
tmp
[
i
]
=
str
[
i
]
;
}
auto_chown
(
str
)
;
}
}
static
void
inline
auto_chmod
(
char
const
*
str
,
mode_t
mode
)
static
void
inline
auto_chmod
(
char
const
*
str
,
mode_t
mode
)
...
@@ -97,9 +111,14 @@ static void inline auto_file(char const *dst,char const *file,char const *conten
...
@@ -97,9 +111,14 @@ static void inline auto_file(char const *dst,char const *file,char const *conten
{
{
log_flow
()
;
log_flow
()
;
log_trace
(
"write file: "
,
dst
,
"/"
,
file
)
;
char
f
[
strlen
(
dst
)
+
1
+
strlen
(
file
)
+
1
]
;
auto_strings
(
f
,
dst
,
"/"
,
file
)
;
log_trace
(
"write file: "
,
f
)
;
if
(
!
file_write_unsafe
(
dst
,
file
,
contents
,
conlen
))
if
(
!
file_write_unsafe
(
dst
,
file
,
contents
,
conlen
))
log_dieusys
(
LOG_EXIT_SYS
,
"write file: "
,
dst
,
"/"
,
file
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write file: "
,
dst
,
"/"
,
file
)
;
auto_chown
(
f
)
;
}
}
static
void
inline
auto_check
(
char
const
*
str
,
mode_t
type
,
mode_t
perm
,
int
what
)
static
void
inline
auto_check
(
char
const
*
str
,
mode_t
type
,
mode_t
perm
,
int
what
)
...
@@ -274,8 +293,8 @@ void write_bootlog(char const *live, char const *scandir)
...
@@ -274,8 +293,8 @@ void write_bootlog(char const *live, char const *scandir)
log_flow
()
;
log_flow
()
;
int
r
;
int
r
;
uid_t
uid
;
uid_t
uid
=
-
1
;
gid_t
gid
;
gid_t
gid
=
-
1
;
size_t
livelen
=
strlen
(
live
),
scandirlen
=
strlen
(
scandir
),
ownerlen
=
uid_fmt
(
OWNERSTR
,
OWNER
),
loglen
=
0
,
blen
=
0
;
size_t
livelen
=
strlen
(
live
),
scandirlen
=
strlen
(
scandir
),
ownerlen
=
uid_fmt
(
OWNERSTR
,
OWNER
),
loglen
=
0
,
blen
=
0
;
buffer
b
;
buffer
b
;
char
path
[
livelen
+
4
+
ownerlen
+
1
]
;
char
path
[
livelen
+
4
+
ownerlen
+
1
]
;
...
@@ -292,6 +311,7 @@ void write_bootlog(char const *live, char const *scandir)
...
@@ -292,6 +311,7 @@ void write_bootlog(char const *live, char const *scandir)
auto_strings
(
logdir
+
loglen
,
"/fifo"
)
;
auto_strings
(
logdir
+
loglen
,
"/fifo"
)
;
auto_fifo
(
logdir
)
;
auto_fifo
(
logdir
)
;
auto_chown
(
logdir
)
;
/** set the log path for the run file
/** set the log path for the run file
* /run/66/log*/
* /run/66/log*/
...
@@ -350,6 +370,7 @@ void write_bootlog(char const *live, char const *scandir)
...
@@ -350,6 +370,7 @@ void write_bootlog(char const *live, char const *scandir)
auto_strings
(
logdir
+
loglen
,
"/run"
)
;
auto_strings
(
logdir
+
loglen
,
"/run"
)
;
auto_chmod
(
logdir
,
0755
)
;
auto_chmod
(
logdir
,
0755
)
;
auto_chown
(
logdir
)
;
}
}
void
write_control
(
char
const
*
scandir
,
char
const
*
live
,
char
const
*
filename
,
int
file
)
void
write_control
(
char
const
*
scandir
,
char
const
*
live
,
char
const
*
filename
,
int
file
)
...
@@ -501,6 +522,7 @@ void write_control(char const *scandir,char const *live, char const *filename, i
...
@@ -501,6 +522,7 @@ void write_control(char const *scandir,char const *live, char const *filename, i
auto_strings
(
mode
+
scandirlen
+
SS_SVSCAN_LOG_LEN
,
filename
)
;
auto_strings
(
mode
+
scandirlen
+
SS_SVSCAN_LOG_LEN
,
filename
)
;
auto_chmod
(
mode
,
0755
)
;
auto_chmod
(
mode
,
0755
)
;
auto_chown
(
mode
)
;
}
}
void
auto_empty_file
(
char
const
*
dst
,
char
const
*
filename
,
char
const
*
contents
)
void
auto_empty_file
(
char
const
*
dst
,
char
const
*
filename
,
char
const
*
contents
)
...
@@ -512,6 +534,8 @@ void auto_empty_file(char const *dst, char const *filename, char const *contents
...
@@ -512,6 +534,8 @@ void auto_empty_file(char const *dst, char const *filename, char const *contents
if
(
!
file_write_unsafe_g
(
tmp
,
contents
))
if
(
!
file_write_unsafe_g
(
tmp
,
contents
))
log_dieusys
(
LOG_EXIT_SYS
,
"create file: "
,
tmp
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"create file: "
,
tmp
)
;
auto_chown
(
tmp
)
;
}
}
static
void
create_service_skel
(
char
const
*
service
,
char
const
*
target
,
char
const
*
notif
)
static
void
create_service_skel
(
char
const
*
service
,
char
const
*
target
,
char
const
*
notif
)
...
@@ -532,8 +556,12 @@ static void create_service_skel(char const *service, char const *target, char co
...
@@ -532,8 +556,12 @@ static void create_service_skel(char const *service, char const *target, char co
if
(
symlink
(
"0"
,
sym
)
<
0
)
if
(
symlink
(
"0"
,
sym
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"symlink: "
,
sym
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"symlink: "
,
sym
)
;
if
(
lchown
(
sym
,
OWNER
,
GIDOWNER
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"chown: "
,
sym
)
;
auto_strings
(
dst
,
target
,
"/"
,
service
,
"/data/rules/gid/0"
)
;
auto_strings
(
dst
,
target
,
"/"
,
service
,
"/data/rules/gid/0"
)
;
auto_dir
(
dst
,
0755
)
;
auto_dir
(
dst
,
0755
)
;
auto_empty_file
(
dst
,
"/allow"
,
""
)
;
auto_empty_file
(
dst
,
"/allow"
,
""
)
;
auto_strings
(
dst
,
target
,
"/"
,
service
,
"/"
)
;
auto_strings
(
dst
,
target
,
"/"
,
service
,
"/"
)
;
...
@@ -567,6 +595,8 @@ static void create_service_oneshot(char const *scandir)
...
@@ -567,6 +595,8 @@ static void create_service_oneshot(char const *scandir)
if
(
chmod
(
dst
,
0755
)
<
0
)
if
(
chmod
(
dst
,
0755
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"chmod: "
,
dst
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"chmod: "
,
dst
)
;
auto_chown
(
dst
)
;
}
}
static
void
create_service_fdholder
(
char
const
*
scandir
)
static
void
create_service_fdholder
(
char
const
*
scandir
)
...
@@ -590,6 +620,8 @@ static void create_service_fdholder(char const *scandir)
...
@@ -590,6 +620,8 @@ static void create_service_fdholder(char const *scandir)
if
(
!
openwritenclose_unsafe
(
dst
,
"^"
SS_FDHOLDER_PIPENAME
"
\n
"
,
SS_FDHOLDER_PIPENAME_LEN
+
2
))
if
(
!
openwritenclose_unsafe
(
dst
,
"^"
SS_FDHOLDER_PIPENAME
"
\n
"
,
SS_FDHOLDER_PIPENAME_LEN
+
2
))
log_dieusys
(
LOG_EXIT_SYS
,
"write: "
,
dst
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write: "
,
dst
)
;
auto_chown
(
dst
)
;
char
sym
[
fdlen
+
48
+
1
]
;
char
sym
[
fdlen
+
48
+
1
]
;
auto_strings
(
sym
,
scandir
,
"/"
,
SS_FDHOLDER
,
"/data/rules/uid/0/env/S6_FDHOLDER_RETRIEVE_REGEX"
)
;
auto_strings
(
sym
,
scandir
,
"/"
,
SS_FDHOLDER
,
"/data/rules/uid/0/env/S6_FDHOLDER_RETRIEVE_REGEX"
)
;
...
@@ -599,6 +631,9 @@ static void create_service_fdholder(char const *scandir)
...
@@ -599,6 +631,9 @@ static void create_service_fdholder(char const *scandir)
if
(
symlink
(
dst
,
sym
)
<
0
)
if
(
symlink
(
dst
,
sym
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"symlink: "
,
dst
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"symlink: "
,
dst
)
;
if
(
lchown
(
sym
,
OWNER
,
GIDOWNER
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"chown: "
,
sym
)
;
auto_strings
(
sym
,
scandir
,
"/"
,
SS_FDHOLDER
,
"/data/rules/gid/0/env"
)
;
auto_strings
(
sym
,
scandir
,
"/"
,
SS_FDHOLDER
,
"/data/rules/gid/0/env"
)
;
auto_strings
(
dst
,
"../../uid/0/env"
)
;
auto_strings
(
dst
,
"../../uid/0/env"
)
;
...
@@ -606,6 +641,9 @@ static void create_service_fdholder(char const *scandir)
...
@@ -606,6 +641,9 @@ static void create_service_fdholder(char const *scandir)
if
(
symlink
(
dst
,
sym
)
<
0
)
if
(
symlink
(
dst
,
sym
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"symlink: "
,
dst
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"symlink: "
,
dst
)
;
if
(
lchown
(
sym
,
OWNER
,
GIDOWNER
)
<
0
)
log_dieusys
(
LOG_EXIT_SYS
,
"chown: "
,
sym
)
;
size_t
runlen
=
strlen
(
SS_EXECLINE_SHEBANGPREFIX
)
+
strlen
(
SS_LIBEXECPREFIX
)
+
277
+
1
;
size_t
runlen
=
strlen
(
SS_EXECLINE_SHEBANGPREFIX
)
+
strlen
(
SS_LIBEXECPREFIX
)
+
277
+
1
;
char
run
[
runlen
]
;
char
run
[
runlen
]
;
...
@@ -630,8 +668,8 @@ static void create_service_fdholder(char const *scandir)
...
@@ -630,8 +668,8 @@ static void create_service_fdholder(char const *scandir)
if
(
!
openwritenclose_unsafe
(
dst
,
run
,
strlen
(
run
)
-
1
))
if
(
!
openwritenclose_unsafe
(
dst
,
run
,
strlen
(
run
)
-
1
))
log_dieusys
(
LOG_EXIT_SYS
,
"write: "
,
dst
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write: "
,
dst
)
;
if
(
chmod
(
dst
,
0755
)
<
0
)
auto_
chmod
(
dst
,
0755
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"chmod: "
,
dst
)
;
auto_chown
(
dst
)
;
auto_strings
(
dst
,
scandir
,
"/"
,
SS_FDHOLDER
,
"/data/autofilled"
)
;
auto_strings
(
dst
,
scandir
,
"/"
,
SS_FDHOLDER
,
"/data/autofilled"
)
;
...
@@ -639,6 +677,7 @@ static void create_service_fdholder(char const *scandir)
...
@@ -639,6 +677,7 @@ static void create_service_fdholder(char const *scandir)
if
(
!
openwritenclose_unsafe
(
dst
,
"
\n
"
,
1
))
if
(
!
openwritenclose_unsafe
(
dst
,
"
\n
"
,
1
))
log_dieusys
(
LOG_EXIT_SYS
,
"write: "
,
dst
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write: "
,
dst
)
;
auto_chown
(
dst
)
;
}
}
void
create_scandir
(
char
const
*
live
,
char
const
*
scandir
)
void
create_scandir
(
char
const
*
live
,
char
const
*
scandir
)
...
@@ -664,12 +703,13 @@ void create_scandir(char const *live, char const *scandir)
...
@@ -664,12 +703,13 @@ void create_scandir(char const *live, char const *scandir)
"/SIGQUIT"
,
"/SIGTERM"
,
"/SIGUSR1"
,
"/SIGUSR2"
,
"/SIGQUIT"
,
"/SIGTERM"
,
"/SIGUSR1"
,
"/SIGUSR2"
,
"/SIGPWR"
,
"/SIGWINCH"
"/SIGPWR"
,
"/SIGWINCH"
}
;
}
;
log_trace
(
"write control file... "
)
;
log_trace
(
"write control file... "
)
;
for
(
int
i
=
0
;
i
<
9
;
i
++
)
for
(
int
i
=
0
;
i
<
9
;
i
++
)
write_control
(
scandir
,
live
,
file
[
i
],
i
)
;
write_control
(
scandir
,
live
,
file
[
i
],
i
)
;
if
(
BOOT
)
if
(
BOOT
)
{
{
if
(
CATCH_LOG
)
if
(
CATCH_LOG
)
write_bootlog
(
live
,
scandir
)
;
write_bootlog
(
live
,
scandir
)
;
...
@@ -712,6 +752,8 @@ void sanitize_live(char const *live)
...
@@ -712,6 +752,8 @@ void sanitize_live(char const *live)
int
ssexec_scandir_create
(
int
argc
,
char
const
*
const
*
argv
,
ssexec_t
*
info
)
int
ssexec_scandir_create
(
int
argc
,
char
const
*
const
*
argv
,
ssexec_t
*
info
)
{
{
log_flow
()
;
int
r
;
int
r
;
CONFIG_STR_LEN
=
compute_buf_size
(
SS_BINPREFIX
,
SS_EXTBINPREFIX
,
SS_EXTLIBEXECPREFIX
,
SS_LIBEXECPREFIX
,
SS_EXECLINE_SHEBANGPREFIX
,
0
)
;
CONFIG_STR_LEN
=
compute_buf_size
(
SS_BINPREFIX
,
SS_EXTBINPREFIX
,
SS_EXTLIBEXECPREFIX
,
SS_LIBEXECPREFIX
,
SS_EXECLINE_SHEBANGPREFIX
,
0
)
;
...
@@ -736,6 +778,9 @@ int ssexec_scandir_create(int argc, char const *const *argv, ssexec_t *info)
...
@@ -736,6 +778,9 @@ int ssexec_scandir_create(int argc, char const *const *argv, ssexec_t *info)
case
'B'
:
case
'B'
:
if
(
OWNER
)
log_die
(
LOG_EXIT_USER
,
"-B options can be set only with root"
)
;
CONTAINER
=
1
;
CONTAINER
=
1
;
BOOT
=
1
;
BOOT
=
1
;
break
;
break
;
...
...
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