Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
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
1
Merge Requests
1
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
settingsd
Commits
87d14422
Commit
87d14422
authored
Feb 10, 2011
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Confidential mode for stdin in execProcess(), additional logging
parent
8d901a6e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
fmod_local_users.py
plugins/functions/fmod_local_users.py
+5
-2
process.py
settingsd/tools/process.py
+13
-7
No files found.
plugins/functions/fmod_local_users.py
View file @
87d14422
...
...
@@ -130,7 +130,7 @@ class LocalUser(service.FunctionObject) :
def
setLock
(
self
,
lock_flag
)
:
(
lock_arg
,
lock_str
)
=
(
(
"-L"
,
"lock"
)
if
lock_flag
else
(
"-U"
,
"unlock"
)
)
logger
.
verbose
(
"{mod}: Request to
%
s local user
\"
%
s
\"
"
%
(
lock_str
))
logger
.
verbose
(
"{mod}: Request to
%
s local user
\"
%
s
\"
"
%
(
lock_str
,
self
.
__user_name
))
proc_args_list
=
[
config
.
value
(
SERVICE_NAME
,
"usermod_bin"
),
lock_arg
,
self
.
__user_name
]
return
tools
.
process
.
execProcess
(
proc_args_list
,
fatal_flag
=
False
)[
2
]
...
...
@@ -147,8 +147,11 @@ class LocalUser(service.FunctionObject) :
@service.functionMethod
(
LOCAL_USER_METHODS_NAMESPACE
,
in_signature
=
"s"
,
out_signature
=
"i"
)
def
setPasswd
(
self
,
passwd
)
:
logger
.
verbose
(
"{mod}: Request to change password for local user
\"
%
s
\"
"
%
(
self
.
__user_name
))
return
tools
.
process
.
execProcess
(
config
.
value
(
SERVICE_NAME
,
"chpasswd_bin"
),
input
=
"
%
s:
%
s
\n
"
%
(
self
.
__user_name
,
passwd
),
fatal_flag
=
False
)[
2
]
proc_input
=
"
%
s:
%
s
\n
"
%
(
self
.
__user_name
,
passwd
),
fatal_flag
=
False
,
confidential_input_flag
=
True
)[
2
]
class
LocalUsers
(
service
.
FunctionObject
)
:
...
...
settingsd/tools/process.py
View file @
87d14422
...
...
@@ -2,6 +2,8 @@
import
subprocess
from
..
import
const
from
..
import
config
from
..
import
logger
...
...
@@ -11,22 +13,26 @@ class SubprocessFailure(Exception) :
##### Public methods #####
def
execProcess
(
args_list
,
input
=
None
,
fatal_flag
=
Tru
e
)
:
logger
.
debug
(
"{submod}: Executing child process
\"
%
s
\"
"
%
(
str
(
args_list
)))
def
execProcess
(
proc_args_list
,
proc_input
=
None
,
fatal_flag
=
True
,
confidential_input_flag
=
Fals
e
)
:
logger
.
debug
(
"{submod}: Executing child process
\"
%
s
\"
"
%
(
str
(
proc_
args_list
)))
proc
=
subprocess
.
Popen
(
args_list
,
shell
=
True
,
bufsize
=
1024
,
close_fds
=
True
,
proc
=
subprocess
.
Popen
(
proc_
args_list
,
shell
=
True
,
bufsize
=
1024
,
close_fds
=
True
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
env
=
{
"LC_ALL"
:
"C"
})
(
proc_stdout
,
proc_stderr
)
=
proc
.
communicate
(
input
)
(
proc_stdout
,
proc_stderr
)
=
proc
.
communicate
(
proc_
input
)
if
proc
.
returncode
!=
0
:
error_text
=
"Error while execute
\"
%
s
\"\n
Stdout:
%
s
\n
Stderr:
%
s
\n
Return code:
%
d"
%
(
str
(
args_list
),
proc_stdout
.
strip
(),
proc_stderr
.
strip
(),
proc
.
returncode
)
if
proc_input
==
None
:
proc_input
=
""
elif
confidential_input_flag
and
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_level"
)
!=
const
.
LOG_LEVEL_DEBUG
:
proc_input
=
"<CONFIDENTIAL>"
error_text
=
"Error while execute
\"
%
s
\"\n
Stdout:
%
s
\n
Stderr:
%
s
\n
Stdin:
%
s
\n
Return code:
%
d"
%
(
str
(
proc_args_list
),
proc_stdout
.
strip
(),
proc_stderr
.
strip
(),
proc_input
,
proc
.
returncode
)
if
fatal_flag
:
raise
SubprocessFailure
(
error_text
)
logger
.
error
(
"{submod}: "
+
error_text
)
logger
.
debug
(
"{submod}: Child process
\"
%
s
\"
finished, return_code=
%
d"
%
(
str
(
args_list
),
proc
.
returncode
))
logger
.
debug
(
"{submod}: Child process
\"
%
s
\"
finished, return_code=
%
d"
%
(
str
(
proc_
args_list
),
proc
.
returncode
))
return
(
proc_stdout
,
proc_stderr
,
proc
.
returncode
)
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