Mercurial > masqmail
comparison src/permissions.c @ 366:41958685480d
Switched to `type *name' style
Andrew Koenig's ``C Traps and Pitfalls'' (Ch.2.1) convinced
me that it is best to go with the way C had been designed.
The ``declaration reflects use'' concept conflicts with a
``type* name'' notation. Hence I switched.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 22 Sep 2011 15:07:40 +0200 |
parents | fc1c6425c024 |
children | b27f66555ba8 |
comparison
equal
deleted
inserted
replaced
365:934a223e4ee8 | 366:41958685480d |
---|---|
51 | 51 |
52 gboolean | 52 gboolean |
53 is_privileged_user(uid_t uid) | 53 is_privileged_user(uid_t uid) |
54 { | 54 { |
55 /* uncomment these lines if you need the `uucp' group to be trusted too | 55 /* uncomment these lines if you need the `uucp' group to be trusted too |
56 struct group* grent = getgrnam("uucp"); | 56 struct group *grent = getgrnam("uucp"); |
57 | 57 |
58 if (is_ingroup(uid, grent->gr_gid)) { | 58 if (is_ingroup(uid, grent->gr_gid)) { |
59 return TRUE; | 59 return TRUE; |
60 } | 60 } |
61 */ | 61 */ |
62 | 62 |
63 return (uid == 0) || (uid == conf.mail_uid) || (is_ingroup(uid, conf.mail_gid)); | 63 return (uid == 0) || (uid == conf.mail_uid) || (is_ingroup(uid, conf.mail_gid)); |
64 } | 64 } |
65 | 65 |
66 void | 66 void |
67 set_euidgid(gint uid, gint gid, uid_t * old_uid, gid_t * old_gid) | 67 set_euidgid(gint uid, gint gid, uid_t *old_uid, gid_t *old_gid) |
68 { | 68 { |
69 if (old_uid) | 69 if (old_uid) |
70 *old_uid = geteuid(); | 70 *old_uid = geteuid(); |
71 if (old_gid) | 71 if (old_gid) |
72 *old_gid = getegid(); | 72 *old_gid = getegid(); |
82 exit(1); | 82 exit(1); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 void | 86 void |
87 set_identity(uid_t old_uid, gchar * task_name) | 87 set_identity(uid_t old_uid, gchar *task_name) |
88 { | 88 { |
89 if (!conf.run_as_user) { | 89 if (!conf.run_as_user) { |
90 if (!is_privileged_user(old_uid)) { | 90 if (!is_privileged_user(old_uid)) { |
91 fprintf(stderr, "must be root, %s or in group %s for %s.\n", DEF_MAIL_USER, DEF_MAIL_GROUP, task_name); | 91 fprintf(stderr, "must be root, %s or in group %s for %s.\n", DEF_MAIL_USER, DEF_MAIL_GROUP, task_name); |
92 exit(1); | 92 exit(1); |