Users: add new option --users-myself-only

This commit is contained in:
Carter Li
2024-06-12 14:02:35 +08:00
committed by 李通洲
parent ebfcd7195e
commit 5bb4dabaec
7 changed files with 89 additions and 17 deletions
+6 -3
View File
@@ -15,15 +15,18 @@
#include <arpa/inet.h>
#endif
const char* ffDetectUsers(FFlist* users)
const char* ffDetectUsers(FFUsersOptions* options, FFlist* users)
{
struct utmpx* n = NULL;
setutxent();
next:
while((n = getutxent()))
while ((n = getutxent()))
{
if(n->ut_type != USER_PROCESS)
if (n->ut_type != USER_PROCESS)
continue;
if (options->myselfOnly && !ffStrbufEqualS(&instance.state.platform.userName, n->ut_user))
continue;
FF_LIST_FOR_EACH(FFUserResult, user, *users)