~ubuntu-branches/ubuntu/saucy/sudo/saucy

« back to all changes in this revision

Viewing changes to src/hooks.c

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-11-16 09:31:32 UTC
  • mfrom: (1.4.13)
  • Revision ID: package-import@ubuntu.com-20121116093132-ptext55adlzbrq6y
Tags: 1.8.6p3-0ubuntu1
* New upstream release (1.8.6p3).
* Add patch to fix building with sssd when ldap is disabled.
* Drop sudo.manpages and sudo-ldap.manpages as the upstream build system
  now does the right thing here.
* Build the main sudo package with support for sssd, this doesn't add any
  additional build time or runtime dependency. sudo will dynamically load
  the sssd library if 'sss' is listed for the 'sudoers' nss service.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
static struct sudo_hook_list *sudo_hook_getenv_list;
61
61
static struct sudo_hook_list *sudo_hook_putenv_list;
62
62
 
 
63
/* NOTE: must not anything that might call setenv() */
63
64
int
64
65
process_hooks_setenv(const char *name, const char *value, int overwrite)
65
66
{
66
67
    struct sudo_hook_list *hook;
67
68
    int rc = SUDO_HOOK_RET_NEXT;
68
 
    debug_decl(process_hooks_setenv, SUDO_DEBUG_HOOKS)
69
69
 
70
70
    /* First process the hooks. */
71
71
    for (hook = sudo_hook_setenv_list; hook != NULL; hook = hook->next) {
77
77
            case SUDO_HOOK_RET_STOP:
78
78
                goto done;
79
79
            default:
80
 
                warningx("invalid setenv hook return value: %d", rc);
 
80
                warningx2("invalid setenv hook return value: %d", rc);
81
81
                break;
82
82
        }
83
83
    }
84
84
done:
85
 
    debug_return_int(rc);
 
85
    return rc;
86
86
}
87
87
 
 
88
/* NOTE: must not anything that might call putenv() */
88
89
int
89
90
process_hooks_putenv(char *string)
90
91
{
91
92
    struct sudo_hook_list *hook;
92
93
    int rc = SUDO_HOOK_RET_NEXT;
93
 
    debug_decl(process_hooks_putenv, SUDO_DEBUG_HOOKS)
94
94
 
95
95
    /* First process the hooks. */
96
96
    for (hook = sudo_hook_putenv_list; hook != NULL; hook = hook->next) {
102
102
            case SUDO_HOOK_RET_STOP:
103
103
                goto done;
104
104
            default:
105
 
                warningx("invalid putenv hook return value: %d", rc);
 
105
                warningx2("invalid putenv hook return value: %d", rc);
106
106
                break;
107
107
        }
108
108
    }
109
109
done:
110
 
    debug_return_int(rc);
 
110
    return rc;
111
111
}
112
112
 
 
113
/* NOTE: must not anything that might call getenv() */
113
114
int
114
115
process_hooks_getenv(const char *name, char **value)
115
116
{
116
117
    struct sudo_hook_list *hook;
117
118
    char *val = NULL;
118
119
    int rc = SUDO_HOOK_RET_NEXT;
119
 
    debug_decl(process_hooks_getenv, SUDO_DEBUG_HOOKS)
120
120
 
121
121
    /* First process the hooks. */
122
122
    for (hook = sudo_hook_getenv_list; hook != NULL; hook = hook->next) {
128
128
            case SUDO_HOOK_RET_STOP:
129
129
                goto done;
130
130
            default:
131
 
                warningx("invalid getenv hook return value: %d", rc);
 
131
                warningx2("invalid getenv hook return value: %d", rc);
132
132
                break;
133
133
        }
134
134
    }
135
135
done:
136
136
    if (val != NULL)
137
137
        *value = val;
138
 
    debug_return_int(rc);
 
138
    return rc;
139
139
}
140
140
 
 
141
/* NOTE: must not anything that might call unsetenv() */
141
142
int
142
143
process_hooks_unsetenv(const char *name)
143
144
{
144
145
    struct sudo_hook_list *hook;
145
146
    int rc = SUDO_HOOK_RET_NEXT;
146
 
    debug_decl(process_hooks_unsetenv, SUDO_DEBUG_HOOKS)
147
147
 
148
148
    /* First process the hooks. */
149
149
    for (hook = sudo_hook_unsetenv_list; hook != NULL; hook = hook->next) {
155
155
            case SUDO_HOOK_RET_STOP:
156
156
                goto done;
157
157
            default:
158
 
                warningx("invalid unsetenv hook return value: %d", rc);
 
158
                warningx2("invalid unsetenv hook return value: %d", rc);
159
159
                break;
160
160
        }
161
161
    }
162
162
done:
163
 
    debug_return_int(rc);
 
163
    return rc;
164
164
}
165
165
 
166
166
/* Hook registration internals. */