Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
stratact
orbutils
Commits
b12832f8
Commit
b12832f8
authored
Jan 29, 2018
by
SamwiseFilmore
Browse files
Port to new redox_users
Also cleaned up some syntax where the new API is used.
parent
ea951687
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
b12832f8
This diff is collapsed.
Click to expand it.
src/orblogin/main.rs
View file @
b12832f8
...
...
@@ -7,13 +7,12 @@ extern crate orbfont;
extern
crate
redox_users
;
use
std
::{
env
,
str
};
use
std
::
os
::
unix
::
process
::
CommandExt
;
use
std
::
process
::
Command
;
use
orbclient
::{
Color
,
EventOption
,
Renderer
,
Window
,
WindowFlag
};
use
orbfont
::
Font
;
use
orbimage
::
Image
;
use
redox_users
::{
get_user_by_name
};
use
redox_users
::{
AllUsers
};
#[derive(Clone,
Copy)]
enum
BackgroundMode
{
...
...
@@ -78,37 +77,27 @@ fn find_scale(image: &Image, mode: BackgroundMode, display_width: u32, display_h
}
fn
login_command
(
username
:
&
str
,
pass
:
&
str
,
launcher_cmd
:
&
str
,
launcher_args
:
&
[
String
])
->
Option
<
Command
>
{
let
sys_users
=
match
AllUsers
::
new
()
{
Ok
(
users
)
=>
users
,
// Not maybe the best thing to do...
Err
(
_
)
=>
{
return
None
;
}
};
match
sys_users
.get_by_name
(
&
username
)
{
Some
(
user
)
=>
if
user
.verify_passwd
(
&
pass
)
{
let
mut
command
=
user
.login_cmd
(
&
launcher_cmd
);
for
arg
in
launcher_args
.iter
()
{
command
.arg
(
&
arg
);
}
let
user_option
=
match
get_user_by_name
(
&
username
)
{
// A little redundant, but a good final check before we actually start verification
Ok
(
user
)
=>
if
username
==
user
.user
&&
(
user
.hash
==
""
||
user
.verify_passwd
(
&
pass
))
{
Some
(
user
)
Some
(
command
)
}
else
{
None
},
Err
(
_
)
=>
None
};
if
let
Some
(
user
)
=
user_option
{
let
mut
command
=
Command
::
new
(
&
launcher_cmd
);
for
arg
in
launcher_args
.iter
()
{
command
.arg
(
&
arg
);
}
command
.uid
(
user
.uid
);
command
.gid
(
user
.gid
);
command
.current_dir
(
user
.home
.clone
());
command
.env
(
"USER"
,
&
username
);
command
.env
(
"UID"
,
format!
(
"{}"
,
user
.uid
));
command
.env
(
"GROUPS"
,
format!
(
"{}"
,
user
.gid
));
command
.env
(
"HOME"
,
user
.home
.clone
());
command
.env
(
"SHELL"
,
user
.shell
);
Some
(
command
)
}
else
{
None
None
=>
None
}
}
...
...
Write
Preview
Supports
Markdown
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