MCPcopy Index your code
hub / github.com/NetHack/NetHack / chdirx

Function chdirx

util/sfctool.c:812–847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810#ifdef UNIX
811#ifdef CHDIR
812void
813chdirx(const char *dir, boolean wr UNUSED)
814{
815 if (dir) {
816#ifdef SECURE
817 (void) setgid(getgid());
818 (void) setuid(getuid()); /* Ron Wessels */
819#endif
820 } else {
821 /* non-default data files is a sign that scores may not be
822 * compatible, or perhaps that a binary not fitting this
823 * system's layout is being used.
824 */
825#ifdef VAR_PLAYGROUND
826 int len = strlen(VAR_PLAYGROUND);
827
828 gf.fqn_prefix[SCOREPREFIX] = (char *) alloc(len + 2);
829 Strcpy(gf.fqn_prefix[SCOREPREFIX], VAR_PLAYGROUND);
830 if (gf.fqn_prefix[SCOREPREFIX][len - 1] != '/') {
831 gf.fqn_prefix[SCOREPREFIX][len] = '/';
832 gf.fqn_prefix[SCOREPREFIX][len + 1] = '\0';
833 }
834
835#endif
836 }
837
838#ifdef HACKDIR
839 if (dir == (const char *) 0)
840 dir = HACKDIR;
841#endif
842
843 if (dir && chdir(dir) < 0) {
844 perror(dir);
845 error("Cannot chdir to %s.", dir);
846 }
847}
848#endif /* CHDIR */
849#endif /* UNIX */
850

Callers 1

mainFunction · 0.70

Calls 4

getuidFunction · 0.85
errorFunction · 0.70
allocFunction · 0.50
chdirFunction · 0.50

Tested by

no test coverage detected