add test for remote ssh commands
This commit is contained in:
27
pkgs/clan-cli/tests/getpwnam-preload.c
Normal file
27
pkgs/clan-cli/tests/getpwnam-preload.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct passwd *(*getpwnam_type)(const char *name);
|
||||
|
||||
struct passwd *getpwnam(const char *name) {
|
||||
struct passwd *pw;
|
||||
getpwnam_type orig_getpwnam;
|
||||
orig_getpwnam = (getpwnam_type)dlsym(RTLD_NEXT, "getpwnam");
|
||||
pw = orig_getpwnam(name);
|
||||
|
||||
if (pw) {
|
||||
const char *shell = getenv("LOGIN_SHELL");
|
||||
if (!shell) {
|
||||
fprintf(stderr, "no LOGIN_SHELL set\n");
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "SHELL:%s\n", shell);
|
||||
pw->pw_shell = strdup(shell);
|
||||
}
|
||||
return pw;
|
||||
}
|
||||
Reference in New Issue
Block a user