From 6f2aa43a3fe722b93eb68a5bb9ae6d4253a352df Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 10 Apr 2024 14:45:56 +0200 Subject: [PATCH] passdb: Use getline(3) to read our old machine sid Don't read the whole file. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/passdb/machine_sid.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c index 16ef6ce266c..c6b8ed403ea 100644 --- a/source3/passdb/machine_sid.c +++ b/source3/passdb/machine_sid.c @@ -21,7 +21,6 @@ */ #include "includes.h" -#include "lib/util/util_file.h" #include "passdb/machine_sid.h" #include "secrets.h" #include "dbwrap/dbwrap.h" @@ -42,19 +41,24 @@ static struct dom_sid *global_sam_sid=NULL; static bool read_sid_from_file(const char *fname, struct dom_sid *sid) { - char **lines; - int numlines; - bool ret; - - lines = file_lines_load(fname, &numlines,0, NULL); + char *line = NULL; + size_t n; + ssize_t len; + bool ret = false; + FILE *f = NULL; + + f = fopen(fname, "r"); + if (f == NULL) { + return false; + } - if (!lines || numlines < 1) { - TALLOC_FREE(lines); - return False; + len = getline(&line, &n, f); + if (len >= 0) { + ret = string_to_sid(sid, line); + SAFE_FREE(line); } - ret = string_to_sid(sid, lines[0]); - TALLOC_FREE(lines); + fclose(f); return ret; } -- 2.11.4.GIT