Skip to content

Commit b4112bb

Browse files
committed
Temporary downgrade to libc 0.1.8
1 parent 00bee9a commit b4112bb

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ license = "GPL-3.0+"
88
keywords = ["smbclient", "samba", "cifs"]
99

1010
[dependencies]
11-
libc = "^0.2.18"
11+
libc = "^0.1.8"
1212
log = "^0.3.6"
1313
smbclient-sys = "^0.1.0"

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
//! # fn main() {}
3131
//! ```
3232
33-
//#![warn(missing_docs)]
34-
3533
#[macro_use]
3634
extern crate log;
3735
extern crate libc;
36+
extern crate smbclient_sys;
3837

3938
#[macro_use]
4039
mod util;

src/smbc.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ use std::ptr;
2828
use std::borrow::Cow;
2929
use std::io::{Read, Write, Seek, SeekFrom};
3030

31-
use libc::{self, c_char, c_int, c_void};
31+
use libc::{self, c_char, c_int, c_void, mode_t, off_t};
3232

33-
use smblient_sys::*;
33+
use smbclient_sys::*;
3434
use util::*;
3535
use result::Result;
3636
// 1}}}
3737

38+
const SMBC_FALSE: smbc_bool = 0;
39+
const SMBC_TRUE: smbc_bool = 1;
40+
3841
// types {{{1
3942
// {{{2
4043
/// ## Basic info
@@ -163,7 +166,7 @@ impl<'a> SmbClient<'a> {
163166
}
164167

165168
/// Auth wrapper passed to `SMBCCTX` to authenticate requests to SMB servers.
166-
unsafe extern "C" fn auth_wrapper<F: 'a>(ctx: *mut SMBCCTX,
169+
extern "C" fn auth_wrapper<F: 'a>(ctx: *mut SMBCCTX,
167170
srv: *const c_char,
168171
shr: *const c_char,
169172
wg: *mut c_char,
@@ -174,21 +177,23 @@ impl<'a> SmbClient<'a> {
174177
pwlen: c_int)
175178
-> ()
176179
where F: for<'b> Fn(&'b str, &'b str) -> (Cow<'a, str>, Cow<'a, str>, Cow<'a, str>) {
177-
let srv = cstr(srv);
178-
let shr = cstr(shr);
179-
trace!(target: "smbc", "authenticating on {}\\{}", &srv, &shr);
180-
181-
let auth: &'a F = mem::transmute(smbc_getOptionUserData(ctx) as *const c_void);
182-
let auth = panic::AssertUnwindSafe(auth);
183-
let r = panic::catch_unwind(|| {
184-
trace!(target: "smbc", "auth with {:?}\\{:?}", srv, shr);
185-
auth(&srv, &shr)
186-
});
187-
let (workgroup, username, password) = r.unwrap_or(DEF_CRED);
188-
trace!(target: "smbc", "cred: {}\\{} {}", &workgroup, &username, &password);
189-
write_to_cstr(wg as *mut u8, wglen as usize, &workgroup);
190-
write_to_cstr(un as *mut u8, unlen as usize, &username);
191-
write_to_cstr(pw as *mut u8, pwlen as usize, &password);
180+
unsafe {
181+
let srv = cstr(srv);
182+
let shr = cstr(shr);
183+
trace!(target: "smbc", "authenticating on {}\\{}", &srv, &shr);
184+
185+
let auth: &'a F = mem::transmute(smbc_getOptionUserData(ctx) as *const c_void);
186+
let auth = panic::AssertUnwindSafe(auth);
187+
let r = panic::catch_unwind(|| {
188+
trace!(target: "smbc", "auth with {:?}\\{:?}", srv, shr);
189+
auth(&srv, &shr)
190+
});
191+
let (workgroup, username, password) = r.unwrap_or(DEF_CRED);
192+
trace!(target: "smbc", "cred: {}\\{} {}", &workgroup, &username, &password);
193+
write_to_cstr(wg as *mut u8, wglen as usize, &workgroup);
194+
write_to_cstr(un as *mut u8, unlen as usize, &username);
195+
write_to_cstr(pw as *mut u8, pwlen as usize, &password);
196+
}
192197
()
193198
}
194199

@@ -425,7 +430,7 @@ impl<'a, 'b> Read for SmbFile<'a, 'b> {
425430
read_fn(self.smbc.ctx,
426431
self.fd,
427432
buf.as_mut_ptr() as *mut c_void,
428-
buf.len())
433+
buf.len() as _)
429434
}));
430435
Ok(bytes_read as usize)
431436
}
@@ -440,7 +445,7 @@ impl<'a, 'b> Write for SmbFile<'a, 'b> {
440445
write_fn(self.smbc.ctx,
441446
self.fd,
442447
buf.as_ptr() as *const c_void,
443-
buf.len())
448+
buf.len() as _)
444449
}));
445450
Ok(bytes_wrote as usize)
446451
}

0 commit comments

Comments
 (0)