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
f3c59c89
Commit
f3c59c89
authored
2 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
add name_isvalid(), set_ownersysdir_stack(), set_ownerhome_stack() functions
parent
e37666f9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lib66/utils/name_isvalid.c
+34
-0
34 additions, 0 deletions
src/lib66/utils/name_isvalid.c
src/lib66/utils/set_ownerhome.c
+28
-0
28 additions, 0 deletions
src/lib66/utils/set_ownerhome.c
src/lib66/utils/set_ownersysdir.c
+35
-0
35 additions, 0 deletions
src/lib66/utils/set_ownersysdir.c
with
97 additions
and
0 deletions
src/lib66/utils/name_isvalid.c
0 → 100644
+
34
−
0
View file @
f3c59c89
/*
* name_isvalid.c
*
* Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org>
*
* All rights reserved.
*
* This file is part of Obarun. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this
* distribution.
* This file may not be copied, modified, propagated, or distributed
* except according to the terms contained in the LICENSE file./
*/
#include
<string.h>
#include
<oblibs/log.h>
#include
<66/constants.h>
#include
<66/utils.h>
void
name_isvalid
(
char
const
*
name
)
{
log_flow
()
;
if
(
!
memcmp
(
name
,
SS_MASTER
+
1
,
6
))
log_die
(
LOG_EXIT_USER
,
"service name: "
,
name
,
": starts with reserved prefix Master"
)
;
if
(
!
strcmp
(
name
,
SS_SERVICE
))
log_die
(
LOG_EXIT_USER
,
"service as service name is a reserved name"
)
;
if
(
!
strcmp
(
name
,
SS_SERVICE
"@"
))
log_die
(
LOG_EXIT_USER
,
"service@ as service name is a reserved name"
)
;
}
This diff is collapsed.
Click to expand it.
src/lib66/utils/set_ownerhome.c
+
28
−
0
View file @
f3c59c89
...
...
@@ -22,6 +22,7 @@
#include
<skalibs/stralloc.h>
#include
<66/utils.h>
#include
<66/constants.h>
int
set_ownerhome
(
stralloc
*
base
,
uid_t
owner
)
{
...
...
@@ -45,3 +46,30 @@ int set_ownerhome(stralloc *base,uid_t owner)
return
1
;
}
int
set_ownerhome_stack
(
char
*
store
)
{
log_flow
()
;
char
const
*
user_home
=
0
;
int
e
=
errno
;
struct
passwd
*
st
=
getpwuid
(
getuid
())
;
errno
=
0
;
if
(
!
st
)
{
if
(
!
errno
)
errno
=
ESRCH
;
return
0
;
}
user_home
=
st
->
pw_dir
;
errno
=
e
;
if
(
!
user_home
)
return
0
;
if
(
strlen
(
user_home
)
+
1
>
SS_MAX_PATH_LEN
)
{
errno
=
ENAMETOOLONG
;
return
0
;
}
auto_strings
(
store
,
user_home
,
"/"
)
;
return
1
;
}
This diff is collapsed.
Click to expand it.
src/lib66/utils/set_ownersysdir.c
+
35
−
0
View file @
f3c59c89
...
...
@@ -52,3 +52,38 @@ int set_ownersysdir(stralloc *base, uid_t owner)
return
1
;
}
int
set_ownersysdir_stack
(
char
*
base
,
uid_t
owner
)
{
log_flow
()
;
char
const
*
user_home
=
NULL
;
int
e
=
errno
;
struct
passwd
*
st
=
getpwuid
(
owner
)
;
errno
=
0
;
if
(
!
st
)
{
if
(
!
errno
)
errno
=
ESRCH
;
return
0
;
}
user_home
=
st
->
pw_dir
;
errno
=
e
;
if
(
user_home
==
NULL
)
return
0
;
if
(
strlen
(
user_home
)
+
1
+
strlen
(
SS_USER_DIR
)
>
SS_MAX_PATH_LEN
)
{
errno
=
ENAMETOOLONG
;
return
0
;
}
if
(
owner
>
0
)
auto_strings
(
base
,
user_home
,
"/"
,
SS_USER_DIR
)
;
else
auto_strings
(
base
,
SS_SYSTEM_DIR
)
;
return
1
;
}
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