netatalk: afprun.c File Reference

netatalk 4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
afprun.c File Reference
`#include <errno.h>`
`#include <grp.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/param.h>`
`#include <sys/types.h>`
`#include <sys/wait.h>`
`#include <unistd.h>`
`#include <atalk/logger.h>`
`#include <atalk/util.h>`

## Macros
#define | USE_SETEUID 1

## Functions
static int | setup_out_fd (void)
static void | gain_root_privilege (void)
| Gain root privilege before doing something.
static void | gain_root_group_privilege (void)
| Ensure our real and effective groups are zero.
static int | become_user_permanently (uid_t uid, gid_t gid)
| Become the specified uid and gid - permanently !
int | afprun (char *cmd, int *outfd)
| run a command
int | afprun_bg (char *cmd)
| Run a command in the background without waiting.

## Macro Definition Documentation

## ◆ USE_SETEUID

#define USE_SETEUID 1

## Function Documentation

## ◆ afprun()

int afprun | ( | char * | cmd,
|  | int * | outfd )

run a command

Note
  being careful about uid/gid handling and putting the output in outfd (or discard it if outfd is NULL).

## ◆ afprun_bg()

int afprun_bg | ( | char * | cmd | ) |

Run a command in the background without waiting.

Note
  being careful about uid/gid handling

## ◆ become_user_permanently()

int become_user_permanently | ( | uid_t | uid,
|  | gid_t | gid )
| static

Become the specified uid and gid - permanently !

Note
  there should be no way back if possible

## ◆ gain_root_group_privilege()

void gain_root_group_privilege | ( | void |  | ) |
| static

Ensure our real and effective groups are zero.

Note
  we want to end up with rgid==egid==0

## ◆ gain_root_privilege()

void gain_root_privilege | ( | void |  | ) |
| static

Gain root privilege before doing something.

Note
  We want to end up with ruid==euid==0

## ◆ setup_out_fd()

int setup_out_fd | ( | void |  | ) |
| static

This is a utility function of afprun().