summaryrefslogtreecommitdiff
path: root/src/libnsss/nsss_shadow_copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnsss/nsss_shadow_copy.c')
-rw-r--r--src/libnsss/nsss_shadow_copy.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libnsss/nsss_shadow_copy.c b/src/libnsss/nsss_shadow_copy.c
new file mode 100644
index 0000000..bb629db
--- /dev/null
+++ b/src/libnsss/nsss_shadow_copy.c
@@ -0,0 +1,21 @@
+/* ISC license. */
+
+#include <string.h>
+#include <errno.h>
+#include "nsss-internal.h"
+
+int nsss_shadow_copy (struct spwd *sp, char *buf, size_t buflen, struct spwd const *sp2, char const *s, size_t len)
+{
+ if (len > buflen) return (errno = ERANGE, 0) ;
+ memcpy(buf, s, len) ;
+ sp->sp_namp = buf + (sp2->sp_namp - s) ;
+ sp->sp_pwdp = buf + (sp2->sp_pwdp - s) ;
+ sp->sp_lstchg = sp2->sp_lstchg ;
+ sp->sp_min = sp2->sp_min ;
+ sp->sp_max = sp2->sp_max ;
+ sp->sp_warn = sp2->sp_warn ;
+ sp->sp_inact = sp2->sp_inact ;
+ sp->sp_expire = sp2->sp_expire ;
+ sp->sp_flag = sp2->sp_flag ;
+ return 1 ;
+}