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

« back to all changes in this revision

Viewing changes to .pc/format-security.patch/ntpd/ntp_config.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:
76
76
 * "logconfig" building blocks
77
77
 */
78
78
struct masks {
79
 
        const char        *name;
80
 
        unsigned long mask;
 
79
        const char * const      name;
 
80
        const u_int32           mask;
81
81
};
82
82
 
83
83
static struct masks logcfg_class[] = {
84
 
        { "clock",              NLOG_OCLOCK },
85
 
        { "peer",               NLOG_OPEER },
86
 
        { "sync",               NLOG_OSYNC },
87
 
        { "sys",                NLOG_OSYS },
88
 
        { (char *)0,    0 }
89
 
};
90
 
 
91
 
static struct masks logcfg_item[] = {
 
84
        { "clock",      NLOG_OCLOCK },
 
85
        { "peer",       NLOG_OPEER },
 
86
        { "sync",       NLOG_OSYNC },
 
87
        { "sys",        NLOG_OSYS },
 
88
        { NULL,         0 }
 
89
};
 
90
 
 
91
/* logcfg_noclass_items[] masks are complete and must not be shifted */
 
92
static struct masks logcfg_noclass_items[] = {
 
93
        { "allall",             NLOG_SYSMASK | NLOG_PEERMASK | NLOG_CLOCKMASK | NLOG_SYNCMASK },
 
94
        { "allinfo",            NLOG_SYSINFO | NLOG_PEERINFO | NLOG_CLOCKINFO | NLOG_SYNCINFO },
 
95
        { "allevents",          NLOG_SYSEVENT | NLOG_PEEREVENT | NLOG_CLOCKEVENT | NLOG_SYNCEVENT },
 
96
        { "allstatus",          NLOG_SYSSTATUS | NLOG_PEERSTATUS | NLOG_CLOCKSTATUS | NLOG_SYNCSTATUS },
 
97
        { "allstatistics",      NLOG_SYSSTATIST | NLOG_PEERSTATIST | NLOG_CLOCKSTATIST | NLOG_SYNCSTATIST },
 
98
        /* the remainder are misspellings of clockall, peerall, sysall, and syncall. */
 
99
        { "allclock",           (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OCLOCK },
 
100
        { "allpeer",            (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OPEER },
 
101
        { "allsys",             (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OSYS },
 
102
        { "allsync",            (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OSYNC },
 
103
        { NULL,                 0 }
 
104
};
 
105
 
 
106
/* logcfg_class_items[] masks are shiftable by NLOG_O* counts */
 
107
static struct masks logcfg_class_items[] = {
 
108
        { "all",                NLOG_INFO | NLOG_EVENT | NLOG_STATUS | NLOG_STATIST },
92
109
        { "info",               NLOG_INFO },
93
 
        { "allinfo",            NLOG_SYSINFO|NLOG_PEERINFO|NLOG_CLOCKINFO|NLOG_SYNCINFO },
94
110
        { "events",             NLOG_EVENT },
95
 
        { "allevents",          NLOG_SYSEVENT|NLOG_PEEREVENT|NLOG_CLOCKEVENT|NLOG_SYNCEVENT },
96
111
        { "status",             NLOG_STATUS },
97
 
        { "allstatus",          NLOG_SYSSTATUS|NLOG_PEERSTATUS|NLOG_CLOCKSTATUS|NLOG_SYNCSTATUS },
98
112
        { "statistics",         NLOG_STATIST },
99
 
        { "allstatistics",      NLOG_SYSSTATIST|NLOG_PEERSTATIST|NLOG_CLOCKSTATIST|NLOG_SYNCSTATIST },
100
 
        { "allclock",           (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OCLOCK },
101
 
        { "allpeer",            (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OPEER },
102
 
        { "allsys",             (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OSYS },
103
 
        { "allsync",            (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OSYNC },
104
 
        { "all",                NLOG_SYSMASK|NLOG_PEERMASK|NLOG_CLOCKMASK|NLOG_SYNCMASK },
105
 
        { (char *)0,    0 }
 
113
        { NULL,                 0 }
106
114
};
107
115
 
108
116
/* Limits */
303
311
} while (0)
304
312
 
305
313
void ntpd_set_tod_using(const char *);
306
 
static unsigned long get_pfxmatch(char **s,struct masks *m);
307
 
static unsigned long get_match(char *s,struct masks *m);
308
 
static unsigned long get_logmask(char *s);
 
314
static u_int32 get_pfxmatch(const char **, struct masks *);
 
315
static u_int32 get_match(const char *, struct masks *);
 
316
static u_int32 get_logmask(const char *);
309
317
static int getnetnum(const char *num,sockaddr_u *addr, int complain,
310
318
                     enum gnn_type a_type);
311
319
static int get_multiple_netnums(const char *num, sockaddr_u *addr,
3581
3589
                                DPRINTF(1, ("searching for %s\n", stoa(&peeraddr)));
3582
3590
 
3583
3591
                                while (!found) {
3584
 
                                        peer = findexistingpeer(&peeraddr, peer, -1);
 
3592
                                        peer = findexistingpeer(&peeraddr, peer, -1, 0);
3585
3593
                                        if (!peer)
3586
3594
                                                break;
3587
3595
                                        if (peer->flags & FLAG_CONFIG)
4025
4033
 * get_pfxmatch - find value for prefixmatch
4026
4034
 * and update char * accordingly
4027
4035
 */
4028
 
static unsigned long
 
4036
static u_int32
4029
4037
get_pfxmatch(
4030
 
        char ** s,
4031
 
        struct masks *m
 
4038
        const char **   pstr,
 
4039
        struct masks *  m
4032
4040
        )
4033
4041
{
4034
 
        while (m->name) {
4035
 
                if (strncmp(*s, m->name, strlen(m->name)) == 0) {
4036
 
                        *s += strlen(m->name);
 
4042
        while (m->name != NULL) {
 
4043
                if (strncmp(*pstr, m->name, strlen(m->name)) == 0) {
 
4044
                        *pstr += strlen(m->name);
4037
4045
                        return m->mask;
4038
4046
                } else {
4039
4047
                        m++;
4045
4053
/*
4046
4054
 * get_match - find logmask value
4047
4055
 */
4048
 
static unsigned long
 
4056
static u_int32
4049
4057
get_match(
4050
 
        char *s,
4051
 
        struct masks *m
 
4058
        const char *    str,
 
4059
        struct masks *  m
4052
4060
        )
4053
4061
{
4054
 
        while (m->name) {
4055
 
                if (strcmp(s, m->name) == 0)
 
4062
        while (m->name != NULL) {
 
4063
                if (strcmp(str, m->name) == 0)
4056
4064
                        return m->mask;
4057
4065
                else
4058
4066
                        m++;
4063
4071
/*
4064
4072
 * get_logmask - build bitmask for ntp_syslogmask
4065
4073
 */
4066
 
static unsigned long
 
4074
static u_int32
4067
4075
get_logmask(
4068
 
        char *s
 
4076
        const char *    str
4069
4077
        )
4070
4078
{
4071
 
        char *t;
4072
 
        unsigned long offset;
4073
 
        unsigned long mask;
4074
 
 
4075
 
        t = s;
 
4079
        const char *    t;
 
4080
        u_int32         offset;
 
4081
        u_int32         mask;
 
4082
 
 
4083
        mask = get_match(str, logcfg_noclass_items);
 
4084
        if (mask != 0)
 
4085
                return mask;
 
4086
 
 
4087
        t = str;
4076
4088
        offset = get_pfxmatch(&t, logcfg_class);
4077
 
        mask   = get_match(t, logcfg_item);
 
4089
        mask   = get_match(t, logcfg_class_items);
4078
4090
 
4079
4091
        if (mask)
4080
4092
                return mask << offset;
4081
4093
        else
4082
 
                msyslog(LOG_ERR, "logconfig: illegal argument %s - ignored", s);
 
4094
                msyslog(LOG_ERR, "logconfig: '%s' not recognized - ignored",
 
4095
                        str);
4083
4096
 
4084
4097
        return 0;
4085
4098
}