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
cc591b04
Commit
cc591b04
authored
May 07, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
esu: move esu code to esu() function
parent
3955f227
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
50 deletions
+61
-50
epm-sh-functions
bin/epm-sh-functions
+56
-0
esu
bin/esu
+5
-50
No files found.
bin/epm-sh-functions
View file @
cc591b04
...
...
@@ -488,6 +488,62 @@ assure_root()
is_root
||
fatal
"run me only under root"
}
esu
()
{
if
is_root
;
then
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"
$*
"
exec
"
$@
"
else
# just shell
showcmd
"su -"
exec
su -
fi
fi
set_pm_type
escape_args
()
{
local
output
=
''
while
[
-n
"
$1
"
]
;
do
if
has_space
"
$1
"
;
then
[
-n
"
$output
"
]
&&
output
=
"
$output
'
$1
'"
||
output
=
"'
$1
'"
else
[
-n
"
$output
"
]
&&
output
=
"
$output
$1
"
||
output
=
"
$1
"
fi
shift
done
echo
"
$output
"
}
escaped
=
"
$(
escape_args
"
$@
"
)
"
# sudo is not accessible, will ask root password
if
!
set_sudo
;
then
#info "Enter root password:"
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"su - -c
$escaped
"
exec
su -
-c
"
$escaped
"
else
# just shell
showcmd
"su -"
exec
su -
fi
fi
#info "You can be asked about your password:"
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"
$SUDO
su - -c
$escaped
"
$SUDO
su -
-c
"
$escaped
"
else
showcmd
"
$SUDO
su -"
$SUDO
su -
fi
}
regexp_subst
()
{
local
expression
=
"
$1
"
...
...
bin/esu
View file @
cc591b04
...
...
@@ -61,55 +61,10 @@ if [ "$1" = "-c" ] ; then
shift
fi
if
is_root
;
then
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"
$*
"
exec
"
$@
"
else
# just shell
showcmd
"su -"
exec
su -
fi
# just an optimization
if
!
is_root
;
then
# need only under user
set_pm_type
fi
set_pm_type
escape_args
()
{
local
output
=
''
while
[
-n
"
$1
"
]
;
do
if
has_space
"
$1
"
;
then
[
-n
"
$output
"
]
&&
output
=
"
$output
'
$1
'"
||
output
=
"'
$1
'"
else
[
-n
"
$output
"
]
&&
output
=
"
$output
$1
"
||
output
=
"
$1
"
fi
shift
done
echo
"
$output
"
}
escaped
=
"
$(
escape_args
"
$@
"
)
"
# sudo is not accessible, will ask root password
if
!
set_sudo
;
then
#info "Enter root password:"
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"su - -c
$escaped
"
exec
su -
-c
"
$escaped
"
else
# just shell
showcmd
"su -"
exec
su -
fi
fi
#info "You can be asked about your password:"
if
[
-n
"
$*
"
]
;
then
[
-n
"
$quiet
"
]
||
showcmd
"
$SUDO
su - -c
$escaped
"
$SUDO
su -
-c
"
$escaped
"
else
showcmd
"
$SUDO
su -"
$SUDO
su -
fi
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