Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
bf2b397c
Commit
bf2b397c
authored
May 21, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
esu: add messages if sudo or su is missed or not accessible
parent
51ee433c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
5 deletions
+44
-5
epm-sh-functions
bin/epm-sh-functions
+41
-1
esu
bin/esu
+3
-4
No files found.
bin/epm-sh-functions
View file @
bf2b397c
...
@@ -504,6 +504,43 @@ assure_root()
...
@@ -504,6 +504,43 @@ assure_root()
is_root
||
fatal
"run me only under root"
is_root
||
fatal
"run me only under root"
}
}
check_su_access
()
{
is_command su
&&
return
[
!
-f
/bin/su
]
&&
warning
"/bin/su is missed. Try install su package (http://altlinux.org/su)."
&&
return
1
local
group
=
"
$(
stat
-c
'%G'
/bin/su
)
"
||
fatal
warning
"Check if you are in
$group
group to have access to su command."
return
1
}
check_sudo_access
()
{
is_command
sudo
&&
return
local
cmd
=
''
local
i
for
i
in
/bin/sudo /usr/bin/sudo
;
do
[
-f
$i
]
&&
cmd
=
"
$i
"
done
[
!
-f
$cmd
]
&&
warning
"sudo command is missed. Try install sudo package (http://altlinux.org/sudo)."
&&
return
1
local
group
=
"
$(
stat
-c
'%G'
$cmd
)
"
||
fatal
warning
"Check if you are in
$group
group to have access to sudo command."
return
1
}
check_sudo_access_only
()
{
is_command
sudo
&&
return
local
cmd
=
''
local
i
for
i
in
/bin/sudo /usr/bin/sudo
;
do
[
-f
$i
]
&&
cmd
=
"
$i
"
done
[
!
-f
$cmd
]
&&
return
1
local
group
=
"
$(
stat
-c
'%G'
$cmd
)
"
||
fatal
warning
"sudo command is presence, but is not accessible for you. Check if you are in
$group
group to have access to sudo command."
return
1
}
esu
()
esu
()
{
{
if
is_root
;
then
if
is_root
;
then
...
@@ -543,9 +580,10 @@ esu()
...
@@ -543,9 +580,10 @@ esu()
escaped
=
"
$(
escape_args
"
$@
"
)
"
escaped
=
"
$(
escape_args
"
$@
"
)
"
check_sudo_access_only
# sudo is not accessible, will ask root password
# sudo is not accessible, will ask root password
if
!
set_sudo
;
then
if
!
set_sudo
;
then
check_su_access
#info "Enter root password:"
#info "Enter root password:"
if
[
-n
"
$*
"
]
;
then
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"su - -c
$escaped
"
[
-n
"
$quiet
"
]
||
showcmd
"su - -c
$escaped
"
...
@@ -557,6 +595,8 @@ esu()
...
@@ -557,6 +595,8 @@ esu()
fi
fi
fi
fi
check_sudo_access
#info "You can be asked about your password:"
#info "You can be asked about your password:"
if
[
-n
"
$*
"
]
;
then
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"
$SUDO
su - -c
$escaped
"
[
-n
"
$quiet
"
]
||
showcmd
"
$SUDO
su - -c
$escaped
"
...
...
bin/esu
View file @
bf2b397c
...
@@ -67,10 +67,9 @@ if [ "$1" = "-c" ] ; then
...
@@ -67,10 +67,9 @@ if [ "$1" = "-c" ] ; then
shift
shift
fi
fi
# just an optimization
# just ignore
if
!
is_root
;
then
if
[
"
$1
"
=
"-"
]
;
then
# need only under user
shift
set_pm_type
fi
fi
esu
"
$@
"
esu
"
$@
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment