Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
users-openslx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
cdn
users-openslx
Commits
7d70259f
Commit
7d70259f
authored
9 years ago
by
Thiago Abdo
Browse files
Options
Downloads
Patches
Plain Diff
Add checks for id and group names
Signed-off-by:
Thiago Abdo
<
tja14@inf.ufpr.br
>
parent
466bf866
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hdd/adduser.sh
+31
-13
31 additions, 13 deletions
hdd/adduser.sh
with
31 additions
and
13 deletions
hdd/adduser.sh
+
31
−
13
View file @
7d70259f
...
...
@@ -55,59 +55,77 @@ shadow=$3
globalFlag
=
$4
username
=
$(
echo
$passwd
|
cut
-d
':'
-f1
)
uID
=
$(
echo
$passwd
|
cut
-d
':'
-f3
)
globalID
=
$(
echo
$uID
|
grep
-e
"^3....$"
)
localID
=
$(
echo
$uID
|
grep
-e
"^2....$"
-e
"^1....$"
)
groupname
=
$(
echo
$group
|
cut
-d
':'
-f1
)
gID
=
$(
echo
$group
|
cut
-d
':'
-f3
)
globalGID
=
$(
echo
$gID
|
grep
-e
"^3....$"
)
localGID
=
$(
echo
$gID
|
grep
-e
"^2....$"
-e
"^1....$"
)
#globalUser
#if not(globalFlag) && globalID
if
[
"
$globalFlag
"
!=
"global"
]
&&
[
-n
"
$globalID
"
]
;
then
#if not(globalFlag) &&
(
globalID
|| globalGID )
if
[
"
$globalFlag
"
!=
"global"
]
&&
(
[
-n
"
$globalID
"
]
||
[
-n
"
$globalGID
"
]
)
;
then
exit
21
fi
#if globalFlag && not(globalID)
if
[
"
$globalFlag
"
=
"global"
]
&&
[
-z
"
$globalID
"
]
;
then
#if globalFlag &&
(
not(globalID)
|| not(globalGID) )
if
[
"
$globalFlag
"
=
"global"
]
&&
(
[
-z
"
$globalID
"
]
||
[
-z
"
$globalGID
"
]
)
;
then
exit
24
fi
#if globalFlag && globalID
if
[
"
$globalFlag
"
=
"global"
]
&&
[
-n
"
$globalID
"
]
;
then
#if globalFlag && globalID
&& globalGID
if
[
"
$globalFlag
"
=
"global"
]
&&
[
-n
"
$globalID
"
]
&&
[
-n
"
$globalGID
"
]
;
then
#add user global
echo
$0
": Usuário global adicionado corretamente"
exit
0
fi
#Uma vez que não possui id global, se nao possuir id local esta fora do range
if
[
-z
"
$localID
"
]
;
then
#Uma vez que não possui
uid ou g
id global, se nao possuir id local esta fora do range
if
[
-z
"
$localID
"
]
||
[
-z
"
$localGID
"
]
;
then
echo
$0
": Usuario fora do range do local accounts"
exit
32
fi
#See if exist the username that we are tryng to add with non local ID
checkNotLocalName
=
$(
cat
/etc/passwd |
cut
-d
':'
-f1
,3 |
grep
-v
-e
":2....$"
-e
":1....$"
|
grep
-e
"^
$username
:"
)
if
[
-z
"
$checkNotLocalName
"
]
;
then
echo
$0
": Usuario não local com mesmo username"
exit
22
fi
#See if exists the group name that we are trying to add with non local GID
checkNotLocalGroupName
=
$(
cat
/etc/group |
grep
-v
-e
":2....:"
-e
":1....:"
|
grep
-e
"^
$groupname
:"
)
if
[
-z
"
$checkNotLocalGroupName
"
]
;
then
echo
$0
": Usuario não local com mesmo group name"
exit
22
fi
checkName
=
$(
cat
/etc/passwd |
cut
-d
':'
-f1-3
|
grep
-e
"^
$username
:"
)
if
[
-z
"
$checkName
"
]
;
then
#remove "$checkName"
echo
$0
": encontrei outro usuario local com o mesmo nome, devo remove-lo"
fi
checkID
=
$(
cat
/etc/passwd |
cut
-d
':'
-f1-3
|
grep
-e
":
$uID
$"
)
if
[
-z
"
$checkID
"
]
;
then
#remove "$checkID"
echo
$0
": encontrei outro usuario local com o mesmo id, devo remove-lo"
fi
#adicionar verificacao de nome e id para group?
checkGName
=
$(
cat
/etc/group |
grep
-e
"^
$groupname
:"
)
if
[
-z
"
$checkGName
"
]
;
then
#remove "$checkGName"
echo
$0
": encontrei outro usuario local com o mesmo nome de grupo, devo remove-lo"
fi
checkGID
=
$(
cat
/etc/group |
grep
-e
":
$gID
:"
)
if
[
-z
"
$checkGID
"
]
;
then
#remove "$checkGID"
echo
$0
": encontrei outro usuario local com o mesmo id de grupo, devo remove-lo"
fi
#add local user
echo
$0
": Usuario local adicionado corretamente"
...
...
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