fix user writing
This commit is contained in:
parent
83fa0c8733
commit
e79cdaffde
@ -103,8 +103,8 @@ const max_line_len = fmt.count(line_fmt, .{
|
|||||||
|
|
||||||
// toLine formats the user in /etc/passwd format, including the EOL
|
// toLine formats the user in /etc/passwd format, including the EOL
|
||||||
pub fn toLine(self: *const User) BoundedArray(u8, max_line_len) {
|
pub fn toLine(self: *const User) BoundedArray(u8, max_line_len) {
|
||||||
var result = BoundedArray(u8, max_line_len).init(max_line_len) catch unreachable;
|
var result = BoundedArray(u8, max_line_len).init(0) catch unreachable;
|
||||||
_ = fmt.bufPrint(result.slice(), line_fmt, .{
|
result.writer().print(line_fmt, .{
|
||||||
self.name,
|
self.name,
|
||||||
self.uid,
|
self.uid,
|
||||||
self.gid,
|
self.gid,
|
||||||
|
@ -202,8 +202,9 @@ test "smoke test" {
|
|||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
while (i < corpus.users.len) : (i += 1) {
|
while (i < corpus.users.len) : (i += 1) {
|
||||||
const user = corpus.users.get(i);
|
const user = corpus.users.get(i);
|
||||||
const line = user.toLine();
|
const line = user.toLine().constSlice();
|
||||||
_ = try os.write(passwd_fd, line.constSlice());
|
std.debug.print("({d}){s}", .{ line.len, line });
|
||||||
|
_ = try os.write(passwd_fd, line);
|
||||||
}
|
}
|
||||||
os.close(passwd_fd);
|
os.close(passwd_fd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user