summaryrefslogtreecommitdiffstats
path: root/src/sss_client/libwbclient
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2015-10-02 10:38:26 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-10-02 12:24:47 +0200
commit568a0090c664d61e0491c2c2e4f8a3b68189a816 (patch)
tree06f02d1221eee05e0ca083fb757654c33b22dfe9 /src/sss_client/libwbclient
parent5322b6c586b96989bff59c7daa8cd94c81808bfa (diff)
tests: Add an integration test for POSIX detectionintg_test
Diffstat (limited to 'src/sss_client/libwbclient')
0 files changed, 0 insertions, 0 deletions
ss="hl com"> * Dean Jansa <djansa@redhat.com> */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <unistd.h> #include <errno.h> #include <signal.h> #include <syslog.h> #include <sys/wait.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <time.h> #include <sys/times.h> #include "btime_int.h" static unsigned int get_btime(void); int main(int argc, char **argv) { int sd; char inmsg[BTIME_MSGLEN]; char btimeonly[BTIME_MSGLEN]; char cookiemsg[BTIME_MSGLEN]; char *outmsg; struct sockaddr_in cli_addr; socklen_t cli_addr_len; ssize_t nbytes; unsigned int local_btime; openlog("btimed", LOG_PID, LOG_USER); /* Running out of (x)inetd the socket was duped onto stdin. */ sd = fileno(stdin); /* Generate the standard btime message */ memset(btimeonly, 0, BTIME_MSGLEN); local_btime = get_btime(); sprintf(btimeonly, "%u\n", local_btime); syslog(LOG_INFO, "started with btime = %u", local_btime); for (;;) { memset(&cli_addr, 0, sizeof cli_addr); memset(inmsg, 0, BTIME_MSGLEN); cli_addr_len = sizeof cli_addr; nbytes = recvfrom(sd, &inmsg, BTIME_MSGLEN, MSG_WAITALL, (struct sockaddr *)&cli_addr, &cli_addr_len); if (nbytes < 0) { /* Bail if we get an error. client side resends * request, no need to retry here. */ syslog(LOG_INFO, "exitting"); exit(0); } if (inmsg[0] == 'B' && inmsg[1] == 'T' ) { /* New style heartbeat with cookie */ /* Copy cookie to message and append timestamp */ memset(cookiemsg, 0, BTIME_MSGLEN); memcpy(cookiemsg, inmsg, COOKIE_LEN); strcpy(cookiemsg + COOKIE_LEN, btimeonly); outmsg = cookiemsg; } else { outmsg = btimeonly; } sendto(sd, outmsg, BTIME_MSGLEN, MSG_DONTWAIT, (struct sockaddr *)&cli_addr, cli_addr_len); } return 0; } /* *--------------------------------------------------------------------------- * * get_btime -- * * Return machine's boot time rounded up to the nearest minute. * * Returns: