~ubuntu-branches/ubuntu/trusty/ntp/trusty-proposed

« back to all changes in this revision

Viewing changes to ntpq/ntpq-subs.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-04-03 07:21:01 UTC
  • mfrom: (4.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20130403072101-v3vt8xcs18b6uhjf
Tags: 1:4.2.6.p5+dfsg-2ubuntu1
* New upstream version, fixing build failure in raring.
* Merge with Debian; remaining changes:
  + debian/ntp.conf, debian/ntpdate.default: Change default server to
    ntp.ubuntu.com.
  + debian/ntpdate.ifup: Stop ntp before running ntpdate when an interface
    comes up, then start again afterwards.
  + debian/ntp.init, debian/rules: Only stop when entering single user mode.
  + Add enforcing AppArmor profile:
    - debian/control: Add Conflicts/Replaces on apparmor-profiles.
    - debian/control: Add Suggests on apparmor.
    - debian/ntp.dirs: Add apparmor directories.
    - debian/ntp.preinst: Force complain on certain upgrades.
    - debian/ntp.postinst: Reload apparmor profile.
    - debian/ntp.postrm: Remove the force-complain file.
    - add debian/apparmor-profile*.
    - debian/rules: install apparmor-profile and apparmor-profile.tunable.
    - debian/README.Debian: Add note on AppArmor.
  + debian/{control,rules}: Add and enable hardened build for PIE.
  + debian/apparmor-profile: Adjust location of drift files.
  + debian/rules, debian/ntp.dirs, debian/source_ntp.py: Add apport hook.
  + debian/ntpdate-debian: Disregard empty ntp.conf files.
  + debian/ntp.preinst: Remove empty /etc/ntp.conf on fresh intallation.
  + debian/ntpdate.ifup: Fix interaction with openntpd.
  + debian/source_ntp.py: Add filter on AppArmor profile names to prevent
    false positives from denials originating in other packages.
  + debian/apparmor-profile: Add samba4 ntp signing socket to ntpd apparmor
    profile.
  + debian/apparmor-profile: adjust for IPv6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
extern char *   chosts[];
15
15
extern char currenthost[];
 
16
extern int currenthostisnum;
16
17
extern int      numhosts;
17
18
int     maxhostlen;
18
19
 
1442
1443
 
1443
1444
        sockaddr_u srcadr;
1444
1445
        sockaddr_u dstadr;
 
1446
        sockaddr_u refidadr;
1445
1447
        u_long srcport = 0;
1446
1448
        char *dstadr_refid = "0.0.0.0";
 
1449
        char *serverlocal;
1447
1450
        size_t drlen;
1448
1451
        u_long stratum = 0;
1449
1452
        long ppoll = 0;
1490
1493
                        case CP_DSTADR:
1491
1494
                        if (decodenetnum(value, &dum_store)) {
1492
1495
                                type = decodeaddrtype(&dum_store);
 
1496
                                havevar[HAVE_DSTADR] = 1;
 
1497
                                dstadr = dum_store;
1493
1498
                                if (pvl == opeervarlist) {
1494
 
                                        havevar[HAVE_DSTADR] = 1;
1495
 
                                        dstadr = dum_store;
1496
 
                                        dstadr_refid = stoa(&dstadr);
 
1499
                                        dstadr_refid = trunc_left(stoa(&dstadr), 15);
1497
1500
                                }
1498
1501
                        }
1499
1502
                        break;
1509
1512
                                        refid_string[i] = '.';
1510
1513
                                        refid_string[i+1] = '\0';
1511
1514
                                        dstadr_refid = refid_string;
1512
 
                                } else if (decodenetnum(value, &dstadr)) {
1513
 
                                        if (SOCK_UNSPEC(&dstadr))
 
1515
                                } else if (decodenetnum(value, &refidadr)) {
 
1516
                                        if (SOCK_UNSPEC(&refidadr))
1514
1517
                                                dstadr_refid = "0.0.0.0";
1515
 
                                        else if (ISREFCLOCKADR(&dstadr))
 
1518
                                        else if (ISREFCLOCKADR(&refidadr))
1516
1519
                                                dstadr_refid =
1517
 
                                                    refnumtoa(&dstadr);
 
1520
                                                    refnumtoa(&refidadr);
1518
1521
                                        else
1519
1522
                                                dstadr_refid =
1520
 
                                                    stoa(&dstadr);
 
1523
                                                    stoa(&refidadr);
1521
1524
                                } else {
1522
1525
                                        havevar[HAVE_REFID] = 0;
1523
1526
                                }
1595
1598
                c = flash3[CTL_PEER_STATVAL(rstatus) & 0x7];
1596
1599
        else
1597
1600
                c = flash2[CTL_PEER_STATVAL(rstatus) & 0x3];
1598
 
        if (numhosts > 1)
1599
 
                fprintf(fp, "%-*s ", maxhostlen, currenthost);
 
1601
        if (numhosts > 1) {
 
1602
                if (peervarlist == pvl && havevar[HAVE_DSTADR]) {
 
1603
                        serverlocal = nntohost_col(&dstadr,
 
1604
                            (size_t)min(LIB_BUFLENGTH - 1, maxhostlen),
 
1605
                            TRUE);
 
1606
                } else {
 
1607
                        if (currenthostisnum)
 
1608
                                serverlocal = trunc_left(currenthost,
 
1609
                                                         maxhostlen);
 
1610
                        else
 
1611
                                serverlocal = currenthost;
 
1612
                }
 
1613
                fprintf(fp, "%-*s ", maxhostlen, serverlocal);
 
1614
        }
1600
1615
        if (AF_UNSPEC == af || AF(&srcadr) == af) {
1601
1616
                strncpy(clock_name, nntohost(&srcadr), sizeof(clock_name));             
1602
1617
                fprintf(fp, "%c%-15.15s ", c, clock_name);
1694
1709
        int af
1695
1710
        )
1696
1711
{
1697
 
        register int i;
1698
 
        char fullname[LENHOSTNAME];
1699
 
        sockaddr_u netnum;
 
1712
        int             i;
 
1713
        char            fullname[LENHOSTNAME];
 
1714
        sockaddr_u      netnum;
 
1715
        char *          name_or_num;
 
1716
        size_t          sl;
1700
1717
 
1701
1718
        if (!dogetassoc(fp))
1702
1719
                return;
1703
1720
 
1704
1721
        for (i = 0; i < numhosts; ++i) {
1705
 
                if (getnetnum(chosts[i], &netnum, fullname, af))
1706
 
                        if ((int)strlen(fullname) > maxhostlen)
1707
 
                                maxhostlen = strlen(fullname);
 
1722
                if (getnetnum(chosts[i], &netnum, fullname, af)) {
 
1723
                        name_or_num = nntohost(&netnum);
 
1724
                        sl = strlen(name_or_num);
 
1725
                        maxhostlen = max(maxhostlen, (int)sl);
 
1726
                }
1708
1727
        }
1709
1728
        if (numhosts > 1)
1710
 
                (void) fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen, "server");
1711
 
        (void) fprintf(fp,
1712
 
                           "     remote           refid      st t when poll reach   delay   offset  jitter\n");
 
1729
                fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen,
 
1730
                        "server (local)");
 
1731
        fprintf(fp,
 
1732
                "     remote           refid      st t when poll reach   delay   offset  jitter\n");
1713
1733
        if (numhosts > 1)
1714
1734
                for (i = 0; i <= maxhostlen; ++i)
1715
 
                (void) fprintf(fp, "=");
1716
 
        (void) fprintf(fp,
1717
 
                           "==============================================================================\n");
 
1735
                        fprintf(fp, "=");
 
1736
        fprintf(fp,
 
1737
                "==============================================================================\n");
1718
1738
 
1719
1739
        for (i = 0; i < numassoc; i++) {
1720
1740
                if (!showall &&