<commit_before>/*
 * $Id: defs.c,v 1.1 1997/10/26 01:02:30 brian Exp $
 */

#include <sys/types.h>
#include <sys/socket.h>

#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#include <unistd.h>

#include "mbuf.h"
#include "log.h"
#include "main.h"
#ifdef __OpenBSD__
#include <util.h>
#else
#include <libutil.h>
#endif
#include "id.h"

static int uid;
static int gid;
static int euid;
static int egid;

void
ID0init()
{
  uid = getuid();
  gid = getgid();
  euid = geteuid();
  egid = getegid();
}

static void
ID0setuser()
{
  if (setreuid(euid, uid) == -1) {
    LogPrintf(LogERROR, "ID0setuser: Unable to setreuid!\n");
    Cleanup(EX_NOPERM);
  }
}

uid_t
ID0realuid()
{
  return uid;
}

static void
ID0set0()
{
  if (setreuid(uid, euid) == -1) {
    LogPrintf(LogERROR, "ID0set0: Unable to setreuid!\n");
    Cleanup(EX_NOPERM);
  }
}

int
ID0ioctl(int fd, unsigned long req, void *arg)
{
  int ret;

  ID0set0();
  ret = ioctl(fd, req, arg);<commit_msg>Use seteuid() instead of setreuid(). The setreuid() page says seteuid is better !<commit_after>/*
 * $Id: id.c,v 1.1 1997/11/09 06:22:40 brian Exp $
 */

#include <sys/types.h>
#include <sys/socket.h>

#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#include <unistd.h>

#include "mbuf.h"
#include "log.h"
#include "main.h"
#ifdef __OpenBSD__
#include <util.h>
#else
#include <libutil.h>
#endif
#include "id.h"

static int uid;
static int gid;
static int euid;
static int egid;

void
ID0init()
{
  uid = getuid();
  gid = getgid();
  euid = geteuid();
  egid = getegid();
}

static void
ID0setuser()
{
  if (seteuid(uid) == -1) {
    LogPrintf(LogERROR, "ID0setuser: Unable to seteuid!\n");
    Cleanup(EX_NOPERM);
  }
}

uid_t
ID0realuid()
{
  return uid;
}

static void
ID0set0()
{
  if (seteuid(euid) == -1) {
    LogPrintf(LogERROR, "ID0set0: Unable to seteuid!\n");
    Cleanup(EX_NOPERM);
  }
}

int
ID0ioctl(int fd, unsigned long req, void *arg)
{
  int ret;

  ID0set0();
  ret = ioctl(fd, req, arg);
{'fraction_non_alphanumeric': 0.17349397590361446, 'fraction_numerical': 0.027951807228915663, 'mean_word_length': 3.850467289719626, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2310970', 'n_tokens_mistral': 958, 'n_tokens_neox': 927, 'n_words': 223}