summaryrefslogtreecommitdiff
path: root/src/libnsss/nsss_switch_shadow_get.c
blob: 4c0a72263fc86d8a38904c953d2cac3e7394d4df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* ISC license. */

#include <errno.h>

#include <skalibs/unix-timed.h>

#include <nsss/nsss-switch.h>
#include "nsss-switch-internal.h"

int nsss_switch_shadow_get (nsss_switch_t *a, struct spwd *sp, stralloc *sa, tain const *deadline, tain *stamp)
{
  unsigned char c = NSSS_SWITCH_SHADOW_GET ;
  if (!nsss_switch_send(a, (char *)&c, 1, deadline, stamp)) return 0 ;
  if (!buffer_timed_get(&a->b, (char *)&c, 1, deadline, stamp)) return 0 ;
  if (c == 255) return 0 ;
  if (c) return (errno = c, 0) ;
  return nsss_switch_shadow_read(&a->b, sp, sa, deadline, stamp) ;
}