2016-06-30 03:56:12 +00:00
|
|
|
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
2016-05-25 03:55:51 +00:00
|
|
|
//! tty related functionality
|
|
|
|
//!
|
2016-06-06 21:57:48 +00:00
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
use crate::tty::{EventedReadWrite, EventedPty, ChildEvent};
|
2018-12-10 17:53:56 +00:00
|
|
|
use crate::term::SizeInfo;
|
|
|
|
use crate::display::OnResize;
|
|
|
|
use crate::config::{Config, Shell};
|
|
|
|
use crate::cli::Options;
|
2018-10-16 17:02:52 +00:00
|
|
|
use mio;
|
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
use libc::{self, c_int, pid_t, winsize, TIOCSCTTY};
|
|
|
|
use nix::pty::openpty;
|
|
|
|
use signal_hook::{self as sighook, iterator::Signals};
|
2018-10-16 17:02:52 +00:00
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
use std::os::unix::{process::CommandExt, io::{FromRawFd, AsRawFd, RawFd}};
|
2018-10-16 17:02:52 +00:00
|
|
|
use std::fs::File;
|
2019-03-12 19:44:47 +00:00
|
|
|
use std::process::{Command, Stdio, Child};
|
2018-10-16 17:02:52 +00:00
|
|
|
use std::ffi::CStr;
|
|
|
|
use std::ptr;
|
|
|
|
use mio::unix::EventedFd;
|
|
|
|
use std::io;
|
2019-03-12 19:44:47 +00:00
|
|
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
2018-09-24 19:06:12 +00:00
|
|
|
|
2016-06-06 21:57:48 +00:00
|
|
|
/// Process ID of child process
|
|
|
|
///
|
|
|
|
/// Necessary to put this in static storage for `sigchld` to have access
|
2019-03-12 19:44:47 +00:00
|
|
|
static PID: AtomicUsize = AtomicUsize::new(0);
|
2016-06-06 21:57:48 +00:00
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
pub fn child_pid() -> pid_t {
|
|
|
|
PID.load(Ordering::Relaxed) as pid_t
|
2016-06-06 21:57:48 +00:00
|
|
|
}
|
2016-05-25 03:55:51 +00:00
|
|
|
|
|
|
|
/// Get the current value of errno
|
|
|
|
fn errno() -> c_int {
|
2016-06-10 03:39:40 +00:00
|
|
|
::errno::errno().0
|
2016-05-25 03:55:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Get raw fds for master/slave ends of a new pty
|
2019-03-12 19:44:47 +00:00
|
|
|
fn make_pty(size: winsize) -> (RawFd, RawFd) {
|
|
|
|
let mut win_size = size;
|
|
|
|
win_size.ws_xpixel = 0;
|
|
|
|
win_size.ws_ypixel = 0;
|
2016-06-10 03:39:40 +00:00
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
let ends = openpty(Some(&win_size), None)
|
|
|
|
.expect("openpty failed");
|
2016-06-10 03:39:40 +00:00
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
(ends.master, ends.slave)
|
2016-06-10 03:39:40 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 03:55:51 +00:00
|
|
|
/// Really only needed on BSD, but should be fine elsewhere
|
|
|
|
fn set_controlling_terminal(fd: c_int) {
|
|
|
|
let res = unsafe {
|
2018-01-08 22:49:01 +00:00
|
|
|
// TIOSCTTY changes based on platform and the `ioctl` call is different
|
|
|
|
// based on architecture (32/64). So a generic cast is used to make sure
|
|
|
|
// there are no issues. To allow such a generic cast the clippy warning
|
|
|
|
// is disabled.
|
2018-12-07 13:58:11 +00:00
|
|
|
#[allow(clippy::cast_lossless)]
|
2018-01-08 22:49:01 +00:00
|
|
|
libc::ioctl(fd, TIOCSCTTY as _, 0)
|
2016-05-25 03:55:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if res < 0 {
|
|
|
|
die!("ioctl TIOCSCTTY failed: {}", errno());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct Passwd<'a> {
|
|
|
|
name: &'a str,
|
|
|
|
passwd: &'a str,
|
|
|
|
uid: libc::uid_t,
|
|
|
|
gid: libc::gid_t,
|
|
|
|
gecos: &'a str,
|
|
|
|
dir: &'a str,
|
|
|
|
shell: &'a str,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return a Passwd struct with pointers into the provided buf
|
|
|
|
///
|
|
|
|
/// # Unsafety
|
|
|
|
///
|
|
|
|
/// If `buf` is changed while `Passwd` is alive, bad thing will almost certainly happen.
|
2018-12-10 17:53:56 +00:00
|
|
|
fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd<'_> {
|
2016-05-25 03:55:51 +00:00
|
|
|
// Create zeroed passwd struct
|
2016-06-10 03:39:40 +00:00
|
|
|
let mut entry: libc::passwd = unsafe { ::std::mem::uninitialized() };
|
2016-05-25 03:55:51 +00:00
|
|
|
|
|
|
|
let mut res: *mut libc::passwd = ptr::null_mut();
|
|
|
|
|
|
|
|
// Try and read the pw file.
|
|
|
|
let uid = unsafe { libc::getuid() };
|
|
|
|
let status = unsafe {
|
2017-01-05 14:21:24 +00:00
|
|
|
libc::getpwuid_r(uid, &mut entry, buf.as_mut_ptr() as *mut _, buf.len(), &mut res)
|
2016-05-25 03:55:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if status < 0 {
|
|
|
|
die!("getpwuid_r failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
if res.is_null() {
|
|
|
|
die!("pw not found");
|
|
|
|
}
|
|
|
|
|
|
|
|
// sanity check
|
|
|
|
assert_eq!(entry.pw_uid, uid);
|
|
|
|
|
|
|
|
// Build a borrowed Passwd struct
|
|
|
|
Passwd {
|
2017-01-16 00:39:22 +00:00
|
|
|
name: unsafe { CStr::from_ptr(entry.pw_name).to_str().unwrap() },
|
|
|
|
passwd: unsafe { CStr::from_ptr(entry.pw_passwd).to_str().unwrap() },
|
2016-05-25 03:55:51 +00:00
|
|
|
uid: entry.pw_uid,
|
|
|
|
gid: entry.pw_gid,
|
2017-01-16 00:39:22 +00:00
|
|
|
gecos: unsafe { CStr::from_ptr(entry.pw_gecos).to_str().unwrap() },
|
|
|
|
dir: unsafe { CStr::from_ptr(entry.pw_dir).to_str().unwrap() },
|
|
|
|
shell: unsafe { CStr::from_ptr(entry.pw_shell).to_str().unwrap() },
|
2016-05-25 03:55:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
pub struct Pty {
|
2019-03-12 19:44:47 +00:00
|
|
|
child: Child,
|
2018-10-16 17:02:52 +00:00
|
|
|
pub fd: File,
|
|
|
|
token: mio::Token,
|
2019-03-12 19:44:47 +00:00
|
|
|
signals: Signals,
|
|
|
|
signals_token: mio::Token,
|
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Pty {
|
|
|
|
/// Resize the pty
|
|
|
|
///
|
|
|
|
/// Tells the kernel that the window size changed with the new pixel
|
|
|
|
/// dimensions and line/column counts.
|
|
|
|
pub fn resize<T: ToWinsize>(&self, size: &T) {
|
|
|
|
let win = size.to_winsize();
|
|
|
|
|
|
|
|
let res = unsafe {
|
|
|
|
libc::ioctl(self.fd.as_raw_fd(), libc::TIOCSWINSZ, &win as *const _)
|
|
|
|
};
|
|
|
|
|
|
|
|
if res < 0 {
|
|
|
|
die!("ioctl TIOCSWINSZ failed: {}", errno());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-23 08:00:52 +00:00
|
|
|
/// Create a new tty and return a handle to interact with it.
|
2018-10-16 17:02:52 +00:00
|
|
|
pub fn new<T: ToWinsize>(
|
|
|
|
config: &Config,
|
|
|
|
options: &Options,
|
|
|
|
size: &T,
|
|
|
|
window_id: Option<usize>,
|
|
|
|
) -> Pty {
|
2019-03-12 19:44:47 +00:00
|
|
|
let win_size = size.to_winsize();
|
2016-05-25 03:55:51 +00:00
|
|
|
let mut buf = [0; 1024];
|
|
|
|
let pw = get_pw_entry(&mut buf);
|
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
let (master, slave) = make_pty(win_size);
|
2016-05-25 03:55:51 +00:00
|
|
|
|
2018-12-03 22:26:59 +00:00
|
|
|
let default_shell = if cfg!(target_os = "macos") {
|
|
|
|
let shell_name = pw.shell.rsplit('/').next().unwrap();
|
|
|
|
let argv = vec![
|
|
|
|
String::from("-c"),
|
|
|
|
format!("exec -a -{} {}", shell_name, pw.shell),
|
|
|
|
];
|
|
|
|
|
|
|
|
Shell::new_with_args("/bin/bash", argv)
|
|
|
|
} else {
|
|
|
|
Shell::new(pw.shell)
|
|
|
|
};
|
|
|
|
let shell = config.shell().unwrap_or(&default_shell);
|
2016-05-25 03:55:51 +00:00
|
|
|
|
2017-09-28 00:29:44 +00:00
|
|
|
let initial_command = options.command().unwrap_or(shell);
|
2017-04-01 23:30:29 +00:00
|
|
|
|
|
|
|
let mut builder = Command::new(initial_command.program());
|
|
|
|
for arg in initial_command.args() {
|
2017-01-23 19:10:26 +00:00
|
|
|
builder.arg(arg);
|
|
|
|
}
|
2016-12-11 06:44:13 +00:00
|
|
|
|
2017-01-23 08:00:52 +00:00
|
|
|
// Setup child stdin/stdout/stderr as slave fd of pty
|
2017-05-28 02:52:58 +00:00
|
|
|
// Ownership of fd is transferred to the Stdio structs and will be closed by them at the end of
|
|
|
|
// this scope. (It is not an issue that the fd is closed three times since File::drop ignores
|
|
|
|
// error on libc::close.)
|
2017-01-23 19:10:26 +00:00
|
|
|
builder.stdin(unsafe { Stdio::from_raw_fd(slave) });
|
|
|
|
builder.stderr(unsafe { Stdio::from_raw_fd(slave) });
|
|
|
|
builder.stdout(unsafe { Stdio::from_raw_fd(slave) });
|
2016-05-25 03:55:51 +00:00
|
|
|
|
2018-11-11 12:55:28 +00:00
|
|
|
// Setup shell environment
|
2017-01-23 08:00:52 +00:00
|
|
|
builder.env("LOGNAME", pw.name);
|
|
|
|
builder.env("USER", pw.name);
|
2018-12-03 22:26:59 +00:00
|
|
|
builder.env("SHELL", pw.shell);
|
2017-01-23 08:00:52 +00:00
|
|
|
builder.env("HOME", pw.dir);
|
2018-09-24 19:06:12 +00:00
|
|
|
|
2017-05-28 03:08:28 +00:00
|
|
|
if let Some(window_id) = window_id {
|
|
|
|
builder.env("WINDOWID", format!("{}", window_id));
|
|
|
|
}
|
2016-05-25 03:55:51 +00:00
|
|
|
|
2017-01-23 08:00:52 +00:00
|
|
|
builder.before_exec(move || {
|
|
|
|
// Create a new process group
|
|
|
|
unsafe {
|
|
|
|
let err = libc::setsid();
|
|
|
|
if err == -1 {
|
|
|
|
die!("Failed to set session id: {}", errno());
|
2016-05-25 03:55:51 +00:00
|
|
|
}
|
2017-01-23 08:00:52 +00:00
|
|
|
}
|
2016-05-25 03:55:51 +00:00
|
|
|
|
2017-01-23 08:00:52 +00:00
|
|
|
set_controlling_terminal(slave);
|
2016-05-25 03:55:51 +00:00
|
|
|
|
2017-01-23 08:00:52 +00:00
|
|
|
// No longer need slave/master fds
|
|
|
|
unsafe {
|
|
|
|
libc::close(slave);
|
|
|
|
libc::close(master);
|
|
|
|
}
|
2016-05-25 03:55:51 +00:00
|
|
|
|
2017-01-23 08:00:52 +00:00
|
|
|
unsafe {
|
|
|
|
libc::signal(libc::SIGCHLD, libc::SIG_DFL);
|
|
|
|
libc::signal(libc::SIGHUP, libc::SIG_DFL);
|
|
|
|
libc::signal(libc::SIGINT, libc::SIG_DFL);
|
|
|
|
libc::signal(libc::SIGQUIT, libc::SIG_DFL);
|
|
|
|
libc::signal(libc::SIGTERM, libc::SIG_DFL);
|
|
|
|
libc::signal(libc::SIGALRM, libc::SIG_DFL);
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
});
|
|
|
|
|
2017-03-14 07:39:26 +00:00
|
|
|
// Handle set working directory option
|
|
|
|
if let Some(ref dir) = options.working_dir {
|
|
|
|
builder.current_dir(dir.as_path());
|
|
|
|
}
|
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
// Prepare signal handling before spawning child
|
|
|
|
let signals = Signals::new(&[sighook::SIGCHLD]).expect("error preparing signal handling");
|
|
|
|
|
2017-01-23 08:00:52 +00:00
|
|
|
match builder.spawn() {
|
|
|
|
Ok(child) => {
|
2019-03-12 19:44:47 +00:00
|
|
|
// Remember child PID so other modules can use it
|
|
|
|
PID.store(child.id() as usize, Ordering::Relaxed);
|
2016-06-06 21:57:48 +00:00
|
|
|
|
2016-09-24 23:11:50 +00:00
|
|
|
unsafe {
|
|
|
|
// Maybe this should be done outside of this function so nonblocking
|
|
|
|
// isn't forced upon consumers. Although maybe it should be?
|
|
|
|
set_nonblocking(master);
|
|
|
|
}
|
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
let pty = Pty {
|
2019-03-12 19:44:47 +00:00
|
|
|
child,
|
|
|
|
fd: unsafe { File::from_raw_fd(master) },
|
|
|
|
token: mio::Token::from(0),
|
|
|
|
signals,
|
|
|
|
signals_token: mio::Token::from(0),
|
2018-10-16 17:02:52 +00:00
|
|
|
};
|
2018-01-06 01:42:55 +00:00
|
|
|
pty.resize(size);
|
2016-12-11 06:44:13 +00:00
|
|
|
pty
|
2017-01-23 08:00:52 +00:00
|
|
|
},
|
|
|
|
Err(err) => {
|
2019-01-07 00:06:57 +00:00
|
|
|
die!("Failed to spawn command: {}", err);
|
2016-05-31 03:44:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
impl EventedReadWrite for Pty {
|
|
|
|
type Reader = File;
|
|
|
|
type Writer = File;
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn register(
|
|
|
|
&mut self,
|
|
|
|
poll: &mio::Poll,
|
2019-03-12 19:44:47 +00:00
|
|
|
token: &mut dyn Iterator<Item = mio::Token>,
|
2018-10-16 17:02:52 +00:00
|
|
|
interest: mio::Ready,
|
|
|
|
poll_opts: mio::PollOpt,
|
|
|
|
) -> io::Result<()> {
|
2019-03-12 19:44:47 +00:00
|
|
|
self.token = token.next().unwrap();
|
2018-10-16 17:02:52 +00:00
|
|
|
poll.register(
|
2019-03-12 19:44:47 +00:00
|
|
|
&EventedFd(&self.fd.as_raw_fd()),
|
2018-10-16 17:02:52 +00:00
|
|
|
self.token,
|
|
|
|
interest,
|
|
|
|
poll_opts
|
2019-03-12 19:44:47 +00:00
|
|
|
)?;
|
|
|
|
|
|
|
|
self.signals_token = token.next().unwrap();
|
|
|
|
poll.register(
|
|
|
|
&self.signals,
|
|
|
|
self.signals_token,
|
|
|
|
mio::Ready::readable(),
|
|
|
|
mio::PollOpt::level()
|
2018-10-16 17:02:52 +00:00
|
|
|
)
|
|
|
|
}
|
2016-05-31 03:44:37 +00:00
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
#[inline]
|
2019-03-12 19:44:47 +00:00
|
|
|
fn reregister(
|
|
|
|
&mut self,
|
|
|
|
poll: &mio::Poll,
|
|
|
|
interest: mio::Ready,
|
|
|
|
poll_opts: mio::PollOpt
|
|
|
|
) -> io::Result<()> {
|
2018-10-16 17:02:52 +00:00
|
|
|
poll.reregister(
|
2019-03-12 19:44:47 +00:00
|
|
|
&EventedFd(&self.fd.as_raw_fd()),
|
2018-10-16 17:02:52 +00:00
|
|
|
self.token,
|
|
|
|
interest,
|
|
|
|
poll_opts
|
2019-03-12 19:44:47 +00:00
|
|
|
)?;
|
|
|
|
|
|
|
|
poll.reregister(
|
|
|
|
&self.signals,
|
|
|
|
self.signals_token,
|
|
|
|
mio::Ready::readable(),
|
|
|
|
mio::PollOpt::level()
|
2018-10-16 17:02:52 +00:00
|
|
|
)
|
2016-05-31 03:44:37 +00:00
|
|
|
}
|
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
#[inline]
|
|
|
|
fn deregister(&mut self, poll: &mio::Poll) -> io::Result<()> {
|
2019-03-12 19:44:47 +00:00
|
|
|
poll.deregister(&EventedFd(&self.fd.as_raw_fd()))?;
|
|
|
|
poll.deregister(&self.signals)
|
2018-10-16 17:02:52 +00:00
|
|
|
}
|
2016-05-31 03:44:37 +00:00
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
#[inline]
|
|
|
|
fn reader(&mut self) -> &mut File {
|
|
|
|
&mut self.fd
|
|
|
|
}
|
2016-05-31 03:44:37 +00:00
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
#[inline]
|
|
|
|
fn read_token(&self) -> mio::Token {
|
|
|
|
self.token
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn writer(&mut self) -> &mut File {
|
|
|
|
&mut self.fd
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn write_token(&self) -> mio::Token {
|
|
|
|
self.token
|
2016-05-25 03:55:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-12 19:44:47 +00:00
|
|
|
impl EventedPty for Pty {
|
|
|
|
#[inline]
|
|
|
|
fn next_child_event(&mut self) -> Option<ChildEvent> {
|
|
|
|
self.signals
|
|
|
|
.pending()
|
|
|
|
.next()
|
|
|
|
.and_then(|signal| {
|
|
|
|
if signal != sighook::SIGCHLD {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
match self.child.try_wait() {
|
|
|
|
Err(e) => {
|
|
|
|
error!("Error checking child process termination: {}", e);
|
|
|
|
None
|
|
|
|
},
|
|
|
|
Ok(None) => None,
|
|
|
|
Ok(_) => Some(ChildEvent::Exited),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
fn child_event_token(&self) -> mio::Token {
|
|
|
|
self.signals_token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn process_should_exit() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
/// Types that can produce a `libc::winsize`
|
|
|
|
pub trait ToWinsize {
|
|
|
|
/// Get a `libc::winsize`
|
|
|
|
fn to_winsize(&self) -> winsize;
|
|
|
|
}
|
|
|
|
|
2016-12-12 17:31:48 +00:00
|
|
|
impl<'a> ToWinsize for &'a SizeInfo {
|
|
|
|
fn to_winsize(&self) -> winsize {
|
|
|
|
winsize {
|
|
|
|
ws_row: self.lines().0 as libc::c_ushort,
|
|
|
|
ws_col: self.cols().0 as libc::c_ushort,
|
|
|
|
ws_xpixel: self.width as libc::c_ushort,
|
|
|
|
ws_ypixel: self.height as libc::c_ushort,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
impl OnResize for i32 {
|
2016-12-12 17:31:48 +00:00
|
|
|
fn on_resize(&mut self, size: &SizeInfo) {
|
2018-10-16 17:02:52 +00:00
|
|
|
let win = size.to_winsize();
|
|
|
|
|
|
|
|
let res = unsafe {
|
|
|
|
libc::ioctl(*self, libc::TIOCSWINSZ, &win as *const _)
|
|
|
|
};
|
|
|
|
|
|
|
|
if res < 0 {
|
|
|
|
die!("ioctl TIOCSWINSZ failed: {}", errno());
|
|
|
|
}
|
2016-12-12 17:31:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-24 23:11:50 +00:00
|
|
|
unsafe fn set_nonblocking(fd: c_int) {
|
2018-10-16 17:02:52 +00:00
|
|
|
use libc::{fcntl, F_GETFL, F_SETFL, O_NONBLOCK};
|
2016-09-24 23:11:50 +00:00
|
|
|
|
|
|
|
let res = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
|
|
|
|
assert_eq!(res, 0);
|
|
|
|
}
|
|
|
|
|
2016-05-25 03:55:51 +00:00
|
|
|
#[test]
|
|
|
|
fn test_get_pw_entry() {
|
|
|
|
let mut buf: [i8; 1024] = [0; 1024];
|
2017-02-03 04:50:48 +00:00
|
|
|
let _pw = get_pw_entry(&mut buf);
|
2016-05-25 03:55:51 +00:00
|
|
|
}
|