Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matt Johnston
dropbear
Commits
93f3c318
Commit
93f3c318
authored
May 10, 2017
by
Matt Johnston
Browse files
switch user when opening authorized_keys
parent
1df5c971
Changes
1
Show whitespace changes
Inline
Side-by-side
svr-authpubkey.c
View file @
93f3c318
...
@@ -201,6 +201,8 @@ static int checkpubkey(char* algo, unsigned int algolen,
...
@@ -201,6 +201,8 @@ static int checkpubkey(char* algo, unsigned int algolen,
unsigned
int
len
,
pos
;
unsigned
int
len
,
pos
;
buffer
*
options_buf
=
NULL
;
buffer
*
options_buf
=
NULL
;
int
line_num
;
int
line_num
;
uid_t
origuid
;
gid_t
origgid
;
TRACE
((
"enter checkpubkey"
))
TRACE
((
"enter checkpubkey"
))
...
@@ -227,8 +229,21 @@ static int checkpubkey(char* algo, unsigned int algolen,
...
@@ -227,8 +229,21 @@ static int checkpubkey(char* algo, unsigned int algolen,
snprintf
(
filename
,
len
+
22
,
"%s/.ssh/authorized_keys"
,
snprintf
(
filename
,
len
+
22
,
"%s/.ssh/authorized_keys"
,
ses
.
authstate
.
pw_dir
);
ses
.
authstate
.
pw_dir
);
/* open the file */
/* open the file as the authenticating user. */
origuid
=
getuid
();
origgid
=
getgid
();
if
((
setegid
(
ses
.
authstate
.
pw_gid
))
<
0
||
(
seteuid
(
ses
.
authstate
.
pw_uid
))
<
0
)
{
dropbear_exit
(
"Failed to set euid"
);
}
authfile
=
fopen
(
filename
,
"r"
);
authfile
=
fopen
(
filename
,
"r"
);
if
((
seteuid
(
origuid
))
<
0
||
(
setegid
(
origgid
))
<
0
)
{
dropbear_exit
(
"Failed to revert euid"
);
}
if
(
authfile
==
NULL
)
{
if
(
authfile
==
NULL
)
{
goto
out
;
goto
out
;
}
}
...
...
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