Guard use of ttyslot() with HAVE_TTYSLOT, fix guard for utmp_setid().

This should make it easier to compile sudo on Android which doesn't
provide a way to write to the utmp file.  Bug #940.
This commit is contained in:
Todd C. Miller
2020-09-17 20:05:30 -06:00
parent a001303285
commit 4f1fff953b

View File

@@ -92,7 +92,7 @@ typedef struct utmp sudo_utmp_t;
# define __e_exit e_exit # define __e_exit e_exit
#endif #endif
#if defined(HAVE_GETUTSID) || defined(HAVE_GETUTXID) || defined(HAVE_GETUTID) #if defined(HAVE_STRUCT_UTMP_UT_ID)
/* /*
* Create ut_id from the new ut_line and the old ut_id. * Create ut_id from the new ut_line and the old ut_id.
*/ */
@@ -124,7 +124,7 @@ utmp_setid(sudo_utmp_t *old, sudo_utmp_t *new)
debug_return; debug_return;
} }
#endif /* HAVE_GETUTSID || HAVE_GETUTXID || HAVE_GETUTID */ #endif /* HAVE_STRUCT_UTMP_UT_ID */
/* /*
* Store time in utmp structure. * Store time in utmp structure.
@@ -272,7 +272,7 @@ utmp_slot(const char *line, int ttyfd)
endttyent(); endttyent();
debug_return_int(tty ? slot : 0); debug_return_int(tty ? slot : 0);
} }
# else # elif defined(HAVE_TTYSLOT)
static int static int
utmp_slot(const char *line, int ttyfd) utmp_slot(const char *line, int ttyfd)
{ {
@@ -294,6 +294,12 @@ utmp_slot(const char *line, int ttyfd)
debug_return_int(slot); debug_return_int(slot);
} }
# else /* !HAVE_TTYSLOT */
static int
utmp_slot(const char *line, int ttyfd)
{
retun -1;
}
# endif /* HAVE_GETTTYENT */ # endif /* HAVE_GETTTYENT */
bool bool