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
|
||||
pub fn toLine(self: *const User) BoundedArray(u8, max_line_len) {
|
||||
var result = BoundedArray(u8, max_line_len).init(max_line_len) catch unreachable;
|
||||
_ = fmt.bufPrint(result.slice(), line_fmt, .{
|
||||
var result = BoundedArray(u8, max_line_len).init(0) catch unreachable;
|
||||
result.writer().print(line_fmt, .{
|
||||
self.name,
|
||||
self.uid,
|
||||
self.gid,
|
||||
|
@ -202,8 +202,9 @@ test "smoke test" {
|
||||
var i: usize = 0;
|
||||
while (i < corpus.users.len) : (i += 1) {
|
||||
const user = corpus.users.get(i);
|
||||
const line = user.toLine();
|
||||
_ = try os.write(passwd_fd, line.constSlice());
|
||||
const line = user.toLine().constSlice();
|
||||
std.debug.print("({d}){s}", .{ line.len, line });
|
||||
_ = try os.write(passwd_fd, line);
|
||||
}
|
||||
os.close(passwd_fd);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user