Skip to content

Reset uid & gid before calling X routines #3

@morgant

Description

@morgant

It's probably a good security practice to reset the uid & gid before calling any X routines, much like xload does:

    /* For security reasons, we reset our uid/gid after doing the necessary
       system initialization and before calling any X routines. */
    InitLoadPoint();

#if !defined(_WIN32) || defined(__CYGWIN__)
    /* reset gid first while still (maybe) root */
    if (setgid(getgid()) == -1) {
      fprintf(stderr, gettext("%s: setgid failed: %s\n"),
    ProgramName, strerror(errno));
      exit(1);
    }
    if (setuid(getuid()) == -1) {
      fprintf(stderr, gettext("%s: setuid failed: %s\n"),
    ProgramName, strerror(errno));
      exit(1);
    }
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions