O nás     Inzerce     KontaktSpolehlivé informace o IT již od roku 2011
Hledat
Nepřehlédněte: Usnadní vám práci: Pozoruhodné IT produkty pro rok 2024
Správa dokumentů
Digitální transformace
Informační systémy
Hlavní rubriky: Informační systémy, Mobilní technologie, Datová centra, Sítě, IT bezpečnost, Software, Hardware, Zkušenosti a názory, Speciály

Pozoruhodné IT produkty 2024
E-knihy o IT zdarma
Manuál Linux
[Linux manuál]

getgrouplist: seznam skupin, do kterých uživatel patří

Originální popis anglicky: getgrouplist - list of groups a user belongs to

Návod, kniha: Linux Programmer's Manual

STRUČNĚ

#include <grp.h>
 
int getgrouplist (const char *user, gid_t group,
gid_t *groups, int *ngroups);

POPIS / INSTRUKCE

The getgrouplist() function scans the group database for all the groups user belongs to. Up to *ngroups group IDs corresponding to these groups are stored in the array groups; the return value from the function is the number of group IDs actually stored. The group group is automatically included in the list of groups returned by getgrouplist().

NÁVRATOVÁ HODNOTA

If *ngroups is smaller than the total number of groups found, then getgrouplist() returns a value of `-1'. In all cases the actual number of groups is stored in *ngroups.

BUGS

The glibc 2.3.2 implementation of this function is broken: it overwrites memory when the actual number of groups is larger than *ngroups.

ODPOVÍDAJÍCÍ

This function is present since glibc 2.2.4.

EXAMPLE

/* This crashes with glibc 2.3.2 */
#include <stdio.h>
#include <stdlib.h>
#include <grp.h>
#include <pwd.h>
int main() { int i, ng = 0; char *user = "who"; /* username here */ gid_t *groups = NULL; struct passwd *pw = getpwnam(user); if (pw == NULL) return 0;
if (getgrouplist(user, pw->pw_gid, NULL, &ng) < 0) { groups = (gid_t *) malloc(ng * sizeof (gid_t)); getgrouplist(user, pw->pw_gid, groups, &ng); }
for(i = 0; i < ng; i++) printf("%d\n", groups[i]);
return 0; }

SOUVISEJÍCÍ

getgroups(3), setgroups(3)
2003-11-18 GNU
©2011-2024 BusinessIT.cz, ISSN 1805-0522 | Názvy použité v textech mohou být ochrannými známkami příslušných vlastníků.
Provozovatel: Bispiral, s.r.o., kontakt: BusinessIT(at)Bispiral.com | Inzerce: Best Online Media, s.r.o., zuzana@online-media.cz
O vydavateli | Pravidla webu BusinessIT.cz a ochrana soukromí | Používáme účetní program Money S3 | pg(9006)