003 File Manager
Current Path:
/usr/src/contrib/ntp/ntpd
usr
/
src
/
contrib
/
ntp
/
ntpd
/
📁
..
📄
Makefile.am
(13.57 KB)
📄
Makefile.in
(78.52 KB)
📄
check_y2k.c
(15.73 KB)
📄
cmd_args.c
(4.25 KB)
📄
complete.conf.in
(3.35 KB)
📄
declcond.h
(793 B)
📄
invoke-ntp.conf.menu
(56 B)
📄
invoke-ntp.conf.texi
(104.37 KB)
📄
invoke-ntp.keys.menu
(56 B)
📄
invoke-ntp.keys.texi
(3.21 KB)
📄
invoke-ntpd.menu
(49 B)
📄
invoke-ntpd.texi
(23.68 KB)
📄
jupiter.h
(9.1 KB)
📄
keyword-gen-utd
(57 B)
📄
keyword-gen.c
(21.99 KB)
📄
ntp.conf.5man
(115.01 KB)
📄
ntp.conf.5mdoc
(101.72 KB)
📄
ntp.conf.def
(100.75 KB)
📄
ntp.conf.html
(126.28 KB)
📄
ntp.conf.man.in
(115.01 KB)
📄
ntp.conf.mdoc.in
(101.71 KB)
📄
ntp.conf.texi
(1.19 KB)
📄
ntp.keys.5man
(3.99 KB)
📄
ntp.keys.5mdoc
(4.25 KB)
📄
ntp.keys.def
(3.65 KB)
📄
ntp.keys.html
(8.37 KB)
📄
ntp.keys.man.in
(3.99 KB)
📄
ntp.keys.mdoc.in
(4.24 KB)
📄
ntp.keys.texi
(1.2 KB)
📄
ntp_config.c
(117.55 KB)
📄
ntp_control.c
(123.14 KB)
📄
ntp_crypto.c
(117.09 KB)
📄
ntp_filegen.c
(13.42 KB)
📄
ntp_io.c
(112.21 KB)
📄
ntp_keyword.h
(73.49 KB)
📄
ntp_leapsec.c
(31.18 KB)
📄
ntp_leapsec.h
(10.95 KB)
📄
ntp_loopfilter.c
(40.05 KB)
📄
ntp_monitor.c
(13.43 KB)
📄
ntp_parser.c
(130.65 KB)
📄
ntp_parser.h
(11.36 KB)
📄
ntp_peer.c
(27.66 KB)
📄
ntp_prio_q.c
(4.54 KB)
📄
ntp_proto.c
(150.76 KB)
📄
ntp_refclock.c
(43.87 KB)
📄
ntp_request.c
(67.25 KB)
📄
ntp_restrict.c
(19.06 KB)
📄
ntp_scanner.c
(20.74 KB)
📄
ntp_scanner.h
(4.43 KB)
📄
ntp_signd.c
(5.24 KB)
📄
ntp_timer.c
(17.69 KB)
📄
ntp_util.c
(22.66 KB)
📄
ntpd-opts.c
(71.91 KB)
📄
ntpd-opts.def
(17.55 KB)
📄
ntpd-opts.h
(14.57 KB)
📄
ntpd.1ntpdman
(32.03 KB)
📄
ntpd.1ntpdmdoc
(29.07 KB)
📄
ntpd.c
(42.16 KB)
📄
ntpd.html
(49.68 KB)
📄
ntpd.man.in
(32.03 KB)
📄
ntpd.mdoc.in
(29.07 KB)
📄
ntpd.texi
(3.25 KB)
📄
ntpdbase-opts.def
(13.21 KB)
📄
ntpsim.c
(17.11 KB)
📄
ppsapi_timepps.h
(497 B)
📄
psl0.conf
(25 B)
📄
psl1.conf
(25 B)
📄
psl2.conf
(37 B)
📄
rc_cmdlength.c
(800 B)
📄
refclock_acts.c
(22.66 KB)
📄
refclock_arbiter.c
(12.15 KB)
📄
refclock_arc.c
(46.85 KB)
📄
refclock_as2201.c
(11.09 KB)
📄
refclock_atom.c
(6.63 KB)
📄
refclock_bancomm.c
(16.11 KB)
📄
refclock_chronolog.c
(7.61 KB)
📄
refclock_chu.c
(45.28 KB)
📄
refclock_conf.c
(7.25 KB)
📄
refclock_datum.c
(22.3 KB)
📄
refclock_dumbclock.c
(8.42 KB)
📄
refclock_fg.c
(6.89 KB)
📄
refclock_gpsdjson.c
(58 KB)
📄
refclock_gpsvme.c
(7.77 KB)
📄
refclock_heath.c
(12.97 KB)
📄
refclock_hopfpci.c
(5.69 KB)
📄
refclock_hopfser.c
(7.41 KB)
📄
refclock_hpgps.c
(16.38 KB)
📄
refclock_irig.c
(30.05 KB)
📄
refclock_jjy.c
(144.27 KB)
📄
refclock_jupiter.c
(25.66 KB)
📄
refclock_leitch.c
(13.27 KB)
📄
refclock_local.c
(5.72 KB)
📄
refclock_msfees.c
(44.66 KB)
📄
refclock_mx4200.c
(41.72 KB)
📄
refclock_neoclock4x.c
(29.08 KB)
📄
refclock_nmea.c
(50.6 KB)
📄
refclock_oncore.c
(121.54 KB)
📄
refclock_palisade.c
(35.15 KB)
📄
refclock_palisade.h
(6.52 KB)
📄
refclock_parse.c
(160.87 KB)
📄
refclock_pcf.c
(4.79 KB)
📄
refclock_pst.c
(8.09 KB)
📄
refclock_ripencc.c
(118.21 KB)
📄
refclock_shm.c
(16.96 KB)
📄
refclock_tpro.c
(4.69 KB)
📄
refclock_true.c
(25.3 KB)
📄
refclock_tsyncpci.c
(28.35 KB)
📄
refclock_tt560.c
(6.12 KB)
📄
refclock_ulink.c
(15.64 KB)
📄
refclock_wwv.c
(79.32 KB)
📄
refclock_wwvb.c
(15.71 KB)
📄
refclock_zyfer.c
(7.38 KB)
Editing: ntp_signd.c
/* Copyright 2008, Red Hat, Inc. Copyright 2008, Andrew Tridgell. Licenced under the same terms as NTP itself. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #ifdef HAVE_NTP_SIGND #include "ntpd.h" #include "ntp_io.h" #include "ntp_stdlib.h" #include "ntp_unixtime.h" #include "ntp_control.h" #include "ntp_string.h" #include <stdio.h> #include <stddef.h> #ifdef HAVE_LIBSCF_H #include <libscf.h> #include <unistd.h> #endif /* HAVE_LIBSCF_H */ #include <sys/un.h> /* socket routines by tridge - from junkcode.samba.org */ /* connect to a unix domain socket */ static int ux_socket_connect(const char *name) { int fd; struct sockaddr_un addr; if (!name) { return -1; } ZERO(addr); addr.sun_family = AF_UNIX; strlcpy(addr.sun_path, name, sizeof(addr.sun_path)); fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) { return -1; } if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { close(fd); return -1; } return fd; } /* keep writing until its all sent */ static int write_all(int fd, const void *buf, size_t len) { size_t total = 0; while (len) { int n = write(fd, buf, len); if (n <= 0) return total; buf = n + (const char *)buf; len -= n; total += n; } return total; } /* keep reading until its all read */ static int read_all(int fd, void *buf, size_t len) { size_t total = 0; while (len) { int n = read(fd, buf, len); if (n <= 0) return total; buf = n + (char *)buf; len -= n; total += n; } return total; } /* send a packet in length prefix format */ static int send_packet(int fd, const char *buf, uint32_t len) { uint32_t net_len = htonl(len); if (write_all(fd, &net_len, sizeof(net_len)) != sizeof(net_len)) return -1; if (write_all(fd, buf, len) != len) return -1; return 0; } /* receive a packet in length prefix format */ static int recv_packet(int fd, char **buf, uint32_t *len) { if (read_all(fd, len, sizeof(*len)) != sizeof(*len)) return -1; *len = ntohl(*len); *buf = emalloc(*len); if (read_all(fd, *buf, *len) != *len) { free(*buf); *buf = NULL; return -1; } return 0; } void send_via_ntp_signd( struct recvbuf *rbufp, /* receive packet pointer */ int xmode, keyid_t xkeyid, int flags, struct pkt *xpkt ) { /* We are here because it was detected that the client * sent an all-zero signature, and we therefore know * it's windows trying to talk to an AD server * * Because we don't want to dive into Samba's secrets * database just to find the long-term kerberos key * that is re-used as the NTP key, we instead hand the * packet over to Samba to sign, and return to us. * * The signing method Samba will use is described by * Microsoft in MS-SNTP, found here: * http://msdn.microsoft.com/en-us/library/cc212930.aspx */ int fd, sendlen; struct samba_key_in { uint32_t version; uint32_t op; uint32_t packet_id; uint32_t key_id_le; struct pkt pkt; } samba_pkt; struct samba_key_out { uint32_t version; uint32_t op; uint32_t packet_id; struct pkt pkt; } samba_reply; char full_socket[256]; char *reply = NULL; uint32_t reply_len; ZERO(samba_pkt); samba_pkt.op = 0; /* Sign message */ /* This will be echoed into the reply - a different * impelementation might want multiple packets * awaiting signing */ samba_pkt.packet_id = 1; /* Swap the byte order back - it's actually little * endian on the wire, but it was read above as * network byte order */ samba_pkt.key_id_le = htonl(xkeyid); samba_pkt.pkt = *xpkt; snprintf(full_socket, sizeof(full_socket), "%s/socket", ntp_signd_socket); fd = ux_socket_connect(full_socket); /* Only continue with this if we can talk to Samba */ if (fd != -1) { /* Send old packet to Samba, expect response */ /* Packet to Samba is quite simple: All values BIG endian except key ID as noted [packet size as BE] - 4 bytes [protocol version (0)] - 4 bytes [packet ID] - 4 bytes [operation (sign message=0)] - 4 bytes [key id] - LITTLE endian (as on wire) - 4 bytes [message to sign] - as marshalled, without signature */ if (send_packet(fd, (char *)&samba_pkt, offsetof(struct samba_key_in, pkt) + LEN_PKT_NOMAC) != 0) { /* Huh? could not talk to Samba... */ close(fd); return; } if (recv_packet(fd, &reply, &reply_len) != 0) { if (reply) { free(reply); } close(fd); return; } /* Return packet is also simple: [packet size] - network byte order - 4 bytes [protocol version (0)] network byte order - - 4 bytes [operation (signed success=3, failure=4)] network byte order - - 4 byte (optional) [signed message] - as provided before, with signature appended */ if (reply_len <= sizeof(samba_reply)) { memcpy(&samba_reply, reply, reply_len); if (ntohl(samba_reply.op) == 3 && reply_len > offsetof(struct samba_key_out, pkt)) { sendlen = reply_len - offsetof(struct samba_key_out, pkt); xpkt = &samba_reply.pkt; sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, 0, xpkt, sendlen); #ifdef DEBUG if (debug) printf( "transmit ntp_signd packet: at %ld %s->%s mode %d keyid %08x len %d\n", current_time, ntoa(&rbufp->dstadr->sin), ntoa(&rbufp->recv_srcadr), xmode, xkeyid, sendlen); #endif } } if (reply) { free(reply); } close(fd); } } #endif
Upload File
Create Folder