~ubuntu-branches/ubuntu/precise/util-linux/precise-proposed

« back to all changes in this revision

Viewing changes to login-utils/checktty.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-06-20 22:31:50 UTC
  • mfrom: (1.6.3 upstream) (4.5.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110620223150-lz8wrv0946ihcz3z
Tags: 2.19.1-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
* Dropped changes:
  - mount.preinst: lsb_release has been fixed in lucid and above to be
    usable without configuration, so we don't have to diverge from Debian
    here anymore.
* Changes merged upstream:
  - sfdisk support for '+' with '-N'
  - mount/umount.c: fix a segfault on umount with empty mtab entry
  - Fix arbitrary unmount with fuse security issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include <string.h>
16
16
#include <stdio.h>
17
17
#include <stdlib.h>
 
18
#include <stdint.h>
18
19
#include <unistd.h>
19
20
#include <time.h>
20
21
#include <sys/stat.h>
31
32
 
32
33
#include "pathnames.h"
33
34
#include "login.h"
34
 
#include "xstrncpy.h"
 
35
#include "strutils.h"
 
36
#include "c.h"
35
37
 
36
38
#ifndef TTY_MAJOR
37
39
#define TTY_MAJOR 4
235
237
        /* compare */
236
238
        while (mask_len > 0) {
237
239
                if (mask_len < 32) {
238
 
                        u_int32_t mask = htonl(~(0xffffffff >> mask_len));
 
240
                        uint32_t mask = htonl(~(0xffffffff >> mask_len));
239
241
 
240
 
                        if ((*(u_int32_t *)&addr.s6_addr[i] & mask) !=
241
 
                            (*(u_int32_t *)&net.sin6_addr.s6_addr[i] & mask))
 
242
                        if ((*(uint32_t *)&addr.s6_addr[i] & mask) !=
 
243
                            (*(uint32_t *)&net.sin6_addr.s6_addr[i] & mask))
242
244
                                goto mismatch;
243
245
                        break;
244
246
                }
245
 
                if (*(u_int32_t *)&addr.s6_addr[i] !=
246
 
                    *(u_int32_t *)&net.sin6_addr.s6_addr[i])
 
247
                if (*(uint32_t *)&addr.s6_addr[i] !=
 
248
                    *(uint32_t *)&net.sin6_addr.s6_addr[i])
247
249
                        goto mismatch;
248
250
                i += 4;
249
251
                mask_len -= 32;
321
323
                if (getaddrinfo(item->ip, NULL, &hints, &info)==0 && info) {
322
324
                        if (info->ai_family == AF_INET) {
323
325
                            struct sockaddr_in *sa =
324
 
                                        (struct sockaddr_in *) info->ai_addr;
 
326
                                        (struct sockaddr_in *) info->ai_addr;
325
327
                            memcpy(hostaddress, &(sa->sin_addr),
326
328
                                        sizeof(sa->sin_addr));
327
329
                        }
328
330
                        else if (info->ai_family == AF_INET6) {
329
331
                            struct sockaddr_in6 *sa =
330
 
                                        (struct sockaddr_in6 *) info->ai_addr;
 
332
                                        (struct sockaddr_in6 *) info->ai_addr;
331
333
                            memcpy(hostaddress, &(sa->sin6_addr),
332
334
                                        sizeof(sa->sin6_addr));
333
335
                        }
340
342
                        printf("getaddrinfo() failed\n");
341
343
 
342
344
        }
343
 
        return 0;
 
345
        return EXIT_SUCCESS;
344
346
}
345
347
#endif /* MAIN_TEST_CHECKTTY */
346
348
 
553
555
        /* there was a default rule, but user didn't match, reject! */
554
556
        printf(_("Login on %s from %s denied by default.\n"), tty, hostname);
555
557
        badlogin(user);
556
 
        sleepexit(1);
 
558
        sleepexit(EXIT_FAILURE);
557
559
    }
558
560
 
559
561
    if (found_match) {
564
566
 
565
567
        printf(_("Login on %s from %s denied.\n"), tty, hostname);
566
568
        badlogin(user);
567
 
        sleepexit(1);
 
569
        sleepexit(EXIT_FAILURE);
568
570
    }
569
571
 
570
572
    /* users not matched in /etc/usertty are by default allowed access