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
751f4bbd
Verified
Commit
751f4bbd
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Revert "[Unix] Use &str instead of String for Passwd values"
This reverts commit
169f0d9d
.
parent
b1d0b7f6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cache.rs
+4
-4
4 additions, 4 deletions
src/cache.rs
src/unix.rs
+15
-15
15 additions, 15 deletions
src/unix.rs
with
19 additions
and
19 deletions
src/cache.rs
+
4
−
4
View file @
751f4bbd
...
@@ -65,8 +65,8 @@ pub struct Cache<'a> {
...
@@ -65,8 +65,8 @@ pub struct Cache<'a> {
pub
context_user
:
UserInfo
<
'a
>
pub
context_user
:
UserInfo
<
'a
>
}
}
impl
Cache
<
'_
>
{
impl
Cache
{
pub
fn
new
<
'a
>
()
->
Cache
<
'a
>
{
pub
fn
new
()
->
Cache
{
let
euid
=
unsafe
{
let
euid
=
unsafe
{
geteuid
()
geteuid
()
};
};
...
@@ -401,8 +401,8 @@ fn get_original_euid() -> uid_t {
...
@@ -401,8 +401,8 @@ fn get_original_euid() -> uid_t {
}
}
lazy_static!
{
lazy_static!
{
static
ref
CACHE
:
Mutex
<
Cache
<
'static
>
>
=
Mutex
::
new
(
Cache
::
new
());
static
ref
CACHE
:
Mutex
<
Cache
>
=
Mutex
::
new
(
Cache
::
new
());
}
}
pub
fn
get_cache
()
->
MutexGuard
<
'static
,
Cache
<
'static
>
>
{
pub
fn
get_cache
()
->
MutexGuard
<
'static
,
Cache
>
{
CACHE
.lock
()
.unwrap
()
CACHE
.lock
()
.unwrap
()
}
}
This diff is collapsed.
Click to expand it.
src/unix.rs
+
15
−
15
View file @
751f4bbd
/* Copyright 2021 Dominik George <dominik.george@teckids.org>
/* Copyright 2021 Dominik George <dominik.george@teckids.org>
65;6203;1c
* Copyright 2021 mirabilos <thorsten.glaser@teckids.org>
* Copyright 2021 mirabilos <thorsten.glaser@teckids.org>
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -20,33 +20,33 @@ use std::io;
...
@@ -20,33 +20,33 @@ use std::io;
use
std
::
mem
::
uninitialized
;
use
std
::
mem
::
uninitialized
;
use
std
::
ptr
::
null_mut
;
use
std
::
ptr
::
null_mut
;
pub
struct
Passwd
<
'a
>
{
pub
struct
Passwd
{
pub
pw_name
:
&
'a
str
,
pub
pw_name
:
String
,
pub
pw_passwd
:
&
'a
str
,
pub
pw_passwd
:
String
,
pub
pw_uid
:
uid_t
,
pub
pw_uid
:
uid_t
,
pub
pw_gid
:
gid_t
,
pub
pw_gid
:
gid_t
,
pub
pw_gecos
:
&
'a
str
,
pub
pw_gecos
:
String
,
pub
pw_dir
:
&
'a
str
,
pub
pw_dir
:
String
,
pub
pw_shell
:
&
'a
str
pub
pw_shell
:
String
}
}
const
MAX_BUFLEN
:
size_t
=
1024
*
1024
;
const
MAX_BUFLEN
:
size_t
=
1024
*
1024
;
fn
getpwxx_fillpw
<
'a
>
(
c_passwd
:
passwd
)
->
Passwd
<
'a
>
{
fn
getpwxx_fillpw
(
c_passwd
:
passwd
)
->
Passwd
{
unsafe
{
unsafe
{
Passwd
{
Passwd
{
pw_name
:
CStr
::
from_ptr
(
c_passwd
.pw_name
)
.to_str
()
.ok
()
.unwrap
(),
pw_name
:
CStr
::
from_ptr
(
c_passwd
.pw_name
)
.to_str
ing_lossy
()
.into_owned
(),
pw_passwd
:
CStr
::
from_ptr
(
c_passwd
.pw_passwd
)
.to_str
()
.ok
()
.unwrap
(),
pw_passwd
:
CStr
::
from_ptr
(
c_passwd
.pw_passwd
)
.to_str
ing_lossy
()
.into_owned
(),
pw_uid
:
c_passwd
.pw_uid
,
pw_uid
:
c_passwd
.pw_uid
,
pw_gid
:
c_passwd
.pw_gid
,
pw_gid
:
c_passwd
.pw_gid
,
pw_gecos
:
CStr
::
from_ptr
(
c_passwd
.pw_gecos
)
.to_str
()
.ok
()
.unwrap
(),
pw_gecos
:
CStr
::
from_ptr
(
c_passwd
.pw_gecos
)
.to_str
ing_lossy
()
.into_owned
(),
pw_dir
:
CStr
::
from_ptr
(
c_passwd
.pw_dir
)
.to_str
()
.ok
()
.unwrap
(),
pw_dir
:
CStr
::
from_ptr
(
c_passwd
.pw_dir
)
.to_str
ing_lossy
()
.into_owned
(),
pw_shell
:
CStr
::
from_ptr
(
c_passwd
.pw_shell
)
.to_str
()
.ok
()
.unwrap
(),
pw_shell
:
CStr
::
from_ptr
(
c_passwd
.pw_shell
)
.to_str
ing_lossy
()
.into_owned
(),
}
}
}
}
}
}
pub
fn
getpwnam_safe
<
'a
>
(
name
:
String
)
->
Result
<
Passwd
<
'a
>
,
io
::
Error
>
{
pub
fn
getpwnam_safe
(
name
:
String
)
->
Result
<
Passwd
,
io
::
Error
>
{
let
res
:
Passwd
;
let
res
:
Passwd
;
unsafe
{
unsafe
{
...
@@ -82,7 +82,7 @@ pub fn getpwnam_safe<'a>(name: String) -> Result<Passwd<'a>, io::Error> {
...
@@ -82,7 +82,7 @@ pub fn getpwnam_safe<'a>(name: String) -> Result<Passwd<'a>, io::Error> {
return
Ok
(
res
);
return
Ok
(
res
);
}
}
pub
fn
getpwuid_safe
<
'a
>
(
uid
:
uid_t
)
->
Result
<
Passwd
<
'a
>
,
io
::
Error
>
{
pub
fn
getpwuid_safe
(
uid
:
uid_t
)
->
Result
<
Passwd
,
io
::
Error
>
{
let
res
:
Passwd
;
let
res
:
Passwd
;
unsafe
{
unsafe
{
...
...
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