~vorlon/ubuntu/natty/sudo/keep_home_by_default

« back to all changes in this revision

Viewing changes to fileops.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-05-11 18:07:03 UTC
  • mfrom: (1.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090511180703-vl2t8cem14g6r61c
Tags: 1.7.0-1ubuntu1
* Merge from debian unstable, remaining changes:
 - debian/rules: Disable lecture, enable tty_tickets by default. (Ubuntu
   specific)
 - Add debian/sudo_root.8: Explanation of root handling through sudo.
   Install it in debian/rules. (Ubuntu specific)
 - sudo.c: If the user successfully authenticated and he is in the 'admin'
   group, then create a stamp ~/.sudo_as_admin_successful. Our default bash
   profile checks for this and displays a short intro about sudo if the
   flag is not present. (Ubuntu specific)
 - env.c: Add "http_proxy" to initial_keepenv_table, so that it is kept
   for "sudo apt-get ...". (Ubuntu specific EBW hack, should disappear at
   some point)
 - debian/{rules,postinst,sudo-ldap.postinst}: Disable init script
   installation. Debian reintroduced it because /var/run tmpfs is not the
   default there, but has been on Ubuntu for ages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 1999-2005 Todd C. Miller <Todd.Miller@courtesan.com>
 
2
 * Copyright (c) 1999-2005, 2007 Todd C. Miller <Todd.Miller@courtesan.com>
3
3
 *
4
4
 * Permission to use, copy, modify, and distribute this software for any
5
5
 * purpose with or without fee is hereby granted, provided that the above
27
27
# include <sys/file.h>
28
28
#endif /* HAVE_FLOCK */
29
29
#include <stdio.h>
 
30
#ifdef HAVE_STRING_H
 
31
# include <string.h>
 
32
#else
 
33
# ifdef HAVE_STRINGS_H
 
34
#  include <strings.h>
 
35
# endif
 
36
#endif /* HAVE_STRING_H */
 
37
#include <ctype.h>
 
38
#include <limits.h>
30
39
#ifdef HAVE_UNISTD_H
31
40
# include <unistd.h>
32
41
#endif /* HAVE_UNISTD_H */
40
49
 
41
50
#include "sudo.h"
42
51
 
 
52
#ifndef LINE_MAX
 
53
# define LINE_MAX 2048
 
54
#endif
 
55
 
43
56
#ifndef lint
44
 
__unused static const char rcsid[] = "$Sudo: fileops.c,v 1.5.2.5 2007/06/12 01:28:41 millert Exp $";
 
57
__unused static const char rcsid[] = "$Sudo: fileops.c,v 1.16 2008/11/09 14:13:12 millert Exp $";
45
58
#endif /* lint */
46
59
 
47
60
/*
139
152
#endif
140
153
}
141
154
#endif
 
155
 
 
156
/*
 
157
 * Read a line of input, remove comments and strip off leading
 
158
 * and trailing spaces.  Returns static storage that is reused.
 
159
 */
 
160
char *
 
161
sudo_parseln(fp)
 
162
    FILE *fp;
 
163
{
 
164
    size_t len;
 
165
    char *cp = NULL;
 
166
    static char buf[LINE_MAX];
 
167
 
 
168
    if (fgets(buf, sizeof(buf), fp) != NULL) {
 
169
        /* Remove comments */
 
170
        if ((cp = strchr(buf, '#')) != NULL)
 
171
            *cp = '\0';
 
172
 
 
173
        /* Trim leading and trailing whitespace/newline */
 
174
        len = strlen(buf);
 
175
        while (len > 0 && isspace(buf[len - 1]))
 
176
            buf[--len] = '\0';
 
177
        for (cp = buf; isblank(*cp); cp++)
 
178
            continue;
 
179
    }
 
180
    return(cp);
 
181
}