Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nss-pam-webapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
magicfelix
nss-pam-webapi
Commits
cff0538f
Verified
Commit
cff0538f
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Fix most warnings
parent
8f6a46fa
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cache.rs
+16
-16
16 additions, 16 deletions
src/cache.rs
src/oauth.rs
+1
-1
1 addition, 1 deletion
src/oauth.rs
src/pam.rs
+2
-2
2 additions, 2 deletions
src/pam.rs
with
19 additions
and
19 deletions
src/cache.rs
+
16
−
16
View file @
cff0538f
...
@@ -78,7 +78,7 @@ impl UserInfo {
...
@@ -78,7 +78,7 @@ impl UserInfo {
///
///
/// Will fill the `passwd` slot on success, or return an error if not successful.
/// Will fill the `passwd` slot on success, or return an error if not successful.
/// This method will only attempt resolution if calling `getpwnam`/`getpwuid` is
/// This method will only attempt resolution if calling `getpwnam`/`getpwuid` is
/// currently considered safe, i.e. the `
is_getpwnam_safe
` flag has not been set
/// currently considered safe, i.e. the `
IS_GETPWNAM_SAFE
` flag has not been set
/// to `false`. It will be set to false if another resolution is currently running,
/// to `false`. It will be set to false if another resolution is currently running,
/// because libc will call back into our backend and we need to break the loop.
/// because libc will call back into our backend and we need to break the loop.
/// This means that e.g. home directory resolution is impossible during an NSS
/// This means that e.g. home directory resolution is impossible during an NSS
...
@@ -123,7 +123,7 @@ impl UserInfo {
...
@@ -123,7 +123,7 @@ impl UserInfo {
/// attempting NSS resolution before doing so (in case only username is filled)
/// attempting NSS resolution before doing so (in case only username is filled)
pub
fn
get_uid
(
&
mut
self
)
->
Result
<
uid_t
,
io
::
Error
>
{
pub
fn
get_uid
(
&
mut
self
)
->
Result
<
uid_t
,
io
::
Error
>
{
if
self
.uid
.is_none
()
&&
self
.passwd
.is_none
()
{
if
self
.uid
.is_none
()
&&
self
.passwd
.is_none
()
{
self
.try_resolve
();
self
.try_resolve
()
.ok
()
;
}
}
match
&
self
.passwd
{
match
&
self
.passwd
{
Some
(
passwd
)
=>
Ok
(
passwd
.pw_uid
),
Some
(
passwd
)
=>
Ok
(
passwd
.pw_uid
),
...
@@ -142,7 +142,7 @@ impl UserInfo {
...
@@ -142,7 +142,7 @@ impl UserInfo {
if
self
.passwd
.is_some
()
&&
self
.passwd
.as_ref
()
.unwrap
()
.pw_uid
!=
uid
{
if
self
.passwd
.is_some
()
&&
self
.passwd
.as_ref
()
.unwrap
()
.pw_uid
!=
uid
{
// Invalidate passwd because UID does not match anymore
// Invalidate passwd because UID does not match anymore
self
.passwd
=
None
;
self
.passwd
=
None
;
self
.try_resolve
();
self
.try_resolve
()
.ok
()
;
}
}
self
.username
=
match
&
self
.passwd
{
self
.username
=
match
&
self
.passwd
{
Some
(
p
)
=>
Some
(
p
.pw_name
.to_string
()),
Some
(
p
)
=>
Some
(
p
.pw_name
.to_string
()),
...
@@ -154,7 +154,7 @@ impl UserInfo {
...
@@ -154,7 +154,7 @@ impl UserInfo {
/// attempting NSS resolution before doing so (in case only uid is filled)
/// attempting NSS resolution before doing so (in case only uid is filled)
pub
fn
get_username
(
&
mut
self
)
->
Result
<
String
,
io
::
Error
>
{
pub
fn
get_username
(
&
mut
self
)
->
Result
<
String
,
io
::
Error
>
{
if
self
.username
.is_none
()
&&
self
.passwd
.is_none
()
{
if
self
.username
.is_none
()
&&
self
.passwd
.is_none
()
{
self
.try_resolve
();
self
.try_resolve
()
.ok
()
;
}
}
match
&
self
.passwd
{
match
&
self
.passwd
{
Some
(
passwd
)
=>
Ok
(
passwd
.pw_name
.to_string
()),
Some
(
passwd
)
=>
Ok
(
passwd
.pw_name
.to_string
()),
...
@@ -173,7 +173,7 @@ impl UserInfo {
...
@@ -173,7 +173,7 @@ impl UserInfo {
if
self
.passwd
.is_some
()
&&
self
.passwd
.as_ref
()
.unwrap
()
.pw_name
!=
self
.username
.as_ref
()
.unwrap
()
.to_string
()
{
if
self
.passwd
.is_some
()
&&
self
.passwd
.as_ref
()
.unwrap
()
.pw_name
!=
self
.username
.as_ref
()
.unwrap
()
.to_string
()
{
// Invalidate passwd because UID does not match anymore
// Invalidate passwd because UID does not match anymore
self
.passwd
=
None
;
self
.passwd
=
None
;
self
.try_resolve
();
self
.try_resolve
()
.ok
()
;
}
}
self
.uid
=
match
&
self
.passwd
{
self
.uid
=
match
&
self
.passwd
{
Some
(
p
)
=>
Some
(
p
.pw_uid
),
Some
(
p
)
=>
Some
(
p
.pw_uid
),
...
@@ -192,7 +192,7 @@ impl UserInfo {
...
@@ -192,7 +192,7 @@ impl UserInfo {
/// attempting NSS resolution before doing so
/// attempting NSS resolution before doing so
pub
fn
get_home_directory
(
&
mut
self
)
->
Result
<
String
,
io
::
Error
>
{
pub
fn
get_home_directory
(
&
mut
self
)
->
Result
<
String
,
io
::
Error
>
{
if
self
.passwd
.is_none
()
{
if
self
.passwd
.is_none
()
{
self
.try_resolve
();
self
.try_resolve
()
.ok
()
;
}
}
match
&
self
.passwd
{
match
&
self
.passwd
{
Some
(
passwd
)
=>
Ok
(
passwd
.pw_dir
.clone
()),
Some
(
passwd
)
=>
Ok
(
passwd
.pw_dir
.clone
()),
...
@@ -359,15 +359,15 @@ fn save_json<O: Serialize>(path: PathBuf, obj: O) -> Result<(), io::Error> {
...
@@ -359,15 +359,15 @@ fn save_json<O: Serialize>(path: PathBuf, obj: O) -> Result<(), io::Error> {
fs
::
write
(
path
,
json
)
fs
::
write
(
path
,
json
)
}
}
static
mut
is_getpwnam_safe
:
bool
=
true
;
static
mut
IS_GETPWNAM_SAFE
:
bool
=
true
;
fn
get_is_getpwnam_safe
()
->
bool
{
fn
get_is_getpwnam_safe
()
->
bool
{
unsafe
{
unsafe
{
is_getpwnam_safe
IS_GETPWNAM_SAFE
}
}
}
}
pub
fn
set_is_getpwnam_safe
(
v
:
bool
)
{
pub
fn
set_is_getpwnam_safe
(
v
:
bool
)
{
unsafe
{
unsafe
{
is_getpwnam_safe
=
v
IS_GETPWNAM_SAFE
=
v
}
}
}
}
...
@@ -390,16 +390,16 @@ fn restore_privileges() {
...
@@ -390,16 +390,16 @@ fn restore_privileges() {
}
}
}
}
static
mut
original_euid
:
uid_t
=
uid_t
::
MAX
;
static
mut
ORIGINAL_EUID
:
uid_t
=
uid_t
::
MAX
;
static
mut
original_euid_set
:
bool
=
false
;
static
mut
ORIGINAL_EUID_SET
:
bool
=
false
;
fn
get_original_euid
()
->
uid_t
{
fn
get_original_euid
()
->
uid_t
{
unsafe
{
unsafe
{
if
!
original_euid_set
{
if
!
ORIGINAL_EUID_SET
{
original_euid
=
geteuid
();
ORIGINAL_EUID
=
geteuid
();
debug!
(
"Original EUID stored as {}"
,
original_euid
);
debug!
(
"Original EUID stored as {}"
,
ORIGINAL_EUID
);
original_euid_set
=
true
;
ORIGINAL_EUID_SET
=
true
;
}
}
original_euid
ORIGINAL_EUID
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/oauth.rs
+
1
−
1
View file @
cff0538f
...
@@ -157,7 +157,7 @@ pub fn get_access_token_password<E: Copy>(conf: &Config, prefix: &str, username:
...
@@ -157,7 +157,7 @@ pub fn get_access_token_password<E: Copy>(conf: &Config, prefix: &str, username:
///
///
/// Takes the same arguments as `get_data_jq`.
/// Takes the same arguments as `get_data_jq`.
fn
get_data
(
conf
:
&
Config
,
prefix
:
&
str
,
endpoint
:
&
str
,
param
:
String
,
token
:
&
BasicTokenResponse
)
->
Result
<
String
,
Box
<
dyn
error
::
Error
>>
{
fn
get_data
(
conf
:
&
Config
,
prefix
:
&
str
,
endpoint
:
&
str
,
param
:
String
,
token
:
&
BasicTokenResponse
)
->
Result
<
String
,
Box
<
dyn
error
::
Error
>>
{
//
/
Extract token as string from deserialized access token
// Extract token as string from deserialized access token
let
access_token
=
token
.access_token
()
.secret
();
let
access_token
=
token
.access_token
()
.secret
();
let
token_type
=
"Bearer"
.to_string
();
// FIXME Probably we need to handle other token types
let
token_type
=
"Bearer"
.to_string
();
// FIXME Probably we need to handle other token types
...
...
This diff is collapsed.
Click to expand it.
src/pam.rs
+
2
−
2
View file @
cff0538f
...
@@ -104,14 +104,14 @@ impl PamServiceModule for PamOidc {
...
@@ -104,14 +104,14 @@ impl PamServiceModule for PamOidc {
set_is_getpwnam_safe
(
false
);
set_is_getpwnam_safe
(
false
);
// 2. ...store the access token (will not go through to $HOME, as getpwnam
// 2. ...store the access token (will not go through to $HOME, as getpwnam
// is locked)
// is locked)
get_context_user
()
.set_access_token
(
t
.clone
());
get_context_user
()
.set_access_token
(
t
.clone
())
.ok
()
;
// 3. ...call getpwnam ourselves without having the cache object locked
// 3. ...call getpwnam ourselves without having the cache object locked
let
passwd
=
getpwnam_safe
(
username
.to_string
());
let
passwd
=
getpwnam_safe
(
username
.to_string
());
if
passwd
.is_ok
()
{
if
passwd
.is_ok
()
{
// 4. ...if getpwnam was successful, store the token again (this time,
// 4. ...if getpwnam was successful, store the token again (this time,
// modulo other errors, it will go through to $HOME)
// modulo other errors, it will go through to $HOME)
get_context_user
()
.set_passwd
(
passwd
.unwrap
());
get_context_user
()
.set_passwd
(
passwd
.unwrap
());
get_context_user
()
.set_access_token
(
t
.clone
());
get_context_user
()
.set_access_token
(
t
.clone
())
.ok
()
;
}
}
// 5. ...unlock getpwnam again (somewhat unnecessary)
// 5. ...unlock getpwnam again (somewhat unnecessary)
set_is_getpwnam_safe
(
true
);
set_is_getpwnam_safe
(
true
);
...
...
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