Skip to content

Commit a0464a7

Browse files
Andrii Sultanovlindig
authored andcommitted
CP-50079: Remove unused unixpwd function and its associated tests
Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
1 parent aa02b52 commit a0464a7

File tree

8 files changed

+0
-247
lines changed

8 files changed

+0
-247
lines changed

unixpwd/c/Makefile

Lines changed: 0 additions & 36 deletions
This file was deleted.

unixpwd/c/main.c

Lines changed: 0 additions & 117 deletions
This file was deleted.

unixpwd/c/unixpwd.c

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -202,60 +202,3 @@ unixpwd_setspw(const char *user, char *password)
202202
ulckpwdf();
203203
return 0;
204204
}
205-
206-
char *
207-
unixpwd_unshadow(void)
208-
{
209-
struct spwd spw,
210-
*sp;
211-
struct passwd pwd,
212-
*pw;
213-
char pwbuf[BUFLEN];
214-
char spbuf[BUFLEN];
215-
216-
char *buf;
217-
int size,
218-
cur;
219-
220-
size = 1024;
221-
cur = 0;
222-
buf = malloc(size);
223-
if (!buf) {
224-
return NULL;
225-
}
226-
227-
setpwent();
228-
while (1) {
229-
char tmp[BUFLEN];
230-
int written;
231-
232-
if (getpwent_r(&pwd, pwbuf, BUFLEN, &pw) != 0 || !pw)
233-
break;
234-
getspnam_r(pw->pw_name, &spw, spbuf, BUFLEN, &sp);
235-
236-
written = snprintf(tmp, BUFLEN, "%s:%s:%d:%d:%s:%s:%s\n",
237-
pw->pw_name,
238-
sp ? sp->sp_pwdp : pw->pw_passwd,
239-
pw->pw_uid,
240-
pw->pw_gid,
241-
pw->pw_gecos, pw->pw_dir, pw->pw_shell);
242-
if (written >= BUFLEN) {
243-
endpwent();
244-
free(buf);
245-
return NULL;
246-
}
247-
while (cur + written > size) {
248-
size = size << 1;
249-
buf = realloc(buf, size);
250-
if (!buf) {
251-
endpwent();
252-
return NULL;
253-
}
254-
}
255-
strncpy(buf + cur, tmp, size - cur);
256-
cur += written;
257-
}
258-
endpwent();
259-
260-
return buf;
261-
}

unixpwd/c/unixpwd.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@
2323
char *unixpwd_get(const char *user);
2424
char *unixpwd_getpwd(const char *user);
2525
char *unixpwd_getspw(const char *user);
26-
/*
27-
* return /etc/passwd as a string but with entries from shadow passwords
28-
* when they exist. The returned string must be passed to free(). On
29-
* error, returns NULL and errno set.
30-
*/
31-
32-
char *unixpwd_unshadow(void);
3326

3427
/*
3528
* update password for user in /etc/passwd and /etc/shadow respectively

unixpwd/c/unixpwd_stubs.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,3 @@ caml_unixpwd_setspw(value caml_user, value caml_password)
119119
caml_failwith(strerror(rc));
120120
CAMLreturn(Val_unit);
121121
}
122-
123-
CAMLprim value
124-
caml_unixpwd_unshadow(value unused)
125-
{
126-
CAMLparam1(unused);
127-
char *passwords;
128-
CAMLlocal1(str);
129-
130-
passwords = unixpwd_unshadow();
131-
if (passwords == NULL && errno != 0)
132-
caml_failwith(strerror(errno));
133-
if (passwords == NULL)
134-
caml_failwith("unspecified error in caml_unixpwd_unshadow()");
135-
136-
str = caml_copy_string(passwords);
137-
free(passwords);
138-
CAMLreturn(str);
139-
}

unixpwd/src/unixpwd.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ module Stubs = struct
2222
external setpwd : string -> string -> unit = "caml_unixpwd_setpwd"
2323

2424
external setspw : string -> string -> unit = "caml_unixpwd_setspw"
25-
26-
external unshadow : unit -> string = "caml_unixpwd_unshadow"
2725
end
2826

2927
exception Error of string
@@ -39,5 +37,3 @@ let get user = wrap (fun () -> Stubs.get user)
3937
let setpwd user pwd = wrap (fun () -> Stubs.setpwd user pwd)
4038

4139
let setspw user pwd = wrap (fun () -> Stubs.setspw user pwd)
42-
43-
let unshadow () = wrap Stubs.unshadow

unixpwd/src/unixpwd.mli

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,3 @@ val setspw : string -> string -> unit
4040
* for [user] in /etc/passwd and /etc/shadow, respectively. They raise
4141
* [Error] on error.
4242
*)
43-
44-
val unshadow : unit -> string
45-
46-
(* [unshadow] returns the contents of /etc/passwd as a string with
47-
* passwords from /etc/shadow for users that have a corresponding entry.
48-
* Raises [Error] on error.
49-
*)

unixpwd/test/main.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ let default_user = "unixpwd"
33
let cycle user rounds n =
44
let pw = Printf.sprintf "unixpwd-%06d" n in
55
Unixpwd.setspw user pw ;
6-
ignore (Unixpwd.unshadow () |> String.length) ;
76
assert (Unixpwd.getspw user = pw) ;
87
Unixpwd.setpwd user pw ;
98
assert (Unixpwd.getpwd user = pw) ;

0 commit comments

Comments
 (0)