From: Volker Lendecke Date: Wed, 10 Apr 2024 12:45:56 +0000 (+0200) Subject: passdb: Use getline(3) to read our old machine sid X-Git-Tag: tdb-1.4.11~885 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f2aa43a3fe722b93eb68a5bb9ae6d4253a352df;p=thirdparty%2Fsamba.git 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 --- 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; }