logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

getgroups.3p (4329B)


  1. '\" et
  2. .TH GETGROUPS "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. getgroups
  12. \(em get supplementary group IDs
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <unistd.h>
  17. .P
  18. int getgroups(int \fIgidsetsize\fP, gid_t \fIgrouplist\fP[]);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIgetgroups\fR()
  23. function shall fill in the array
  24. .IR grouplist
  25. with the current supplementary group IDs of the calling process. It is
  26. implementation-defined whether
  27. \fIgetgroups\fR()
  28. also returns the effective group ID in the
  29. .IR grouplist
  30. array.
  31. .P
  32. The
  33. .IR gidsetsize
  34. argument specifies the number of elements in the array
  35. .IR grouplist .
  36. The actual number of group IDs stored in the array shall be returned.
  37. The values of array entries with indices greater than or equal to the
  38. value returned are undefined.
  39. .P
  40. If
  41. .IR gidsetsize
  42. is 0,
  43. \fIgetgroups\fR()
  44. shall return the number of group IDs that it would otherwise return
  45. without modifying the array pointed to by
  46. .IR grouplist .
  47. .P
  48. If the effective group ID of the process is returned with the
  49. supplementary group IDs, the value returned shall always be greater
  50. than or equal to one and less than or equal to the value of
  51. {NGROUPS_MAX}+1.
  52. .SH "RETURN VALUE"
  53. Upon successful completion, the number of supplementary group IDs shall
  54. be returned. A return value of \-1 indicates failure and
  55. .IR errno
  56. shall be set to indicate the error.
  57. .SH ERRORS
  58. The
  59. \fIgetgroups\fR()
  60. function shall fail if:
  61. .TP
  62. .BR EINVAL
  63. The
  64. .IR gidsetsize
  65. argument is non-zero and less than the number of group IDs that would
  66. have been returned.
  67. .LP
  68. .IR "The following sections are informative."
  69. .SH EXAMPLES
  70. .SS "Getting the Supplementary Group IDs of the Calling Process"
  71. .P
  72. The following example places the current supplementary group IDs of the
  73. calling process into the
  74. .IR group
  75. array.
  76. .sp
  77. .RS 4
  78. .nf
  79. #include <sys/types.h>
  80. #include <unistd.h>
  81. \&...
  82. gid_t *group;
  83. int nogroups;
  84. long ngroups_max;
  85. .P
  86. ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
  87. group = (gid_t *)malloc(ngroups_max *sizeof(gid_t));
  88. .P
  89. ngroups = getgroups(ngroups_max, group);
  90. .fi
  91. .P
  92. .RE
  93. .SH "APPLICATION USAGE"
  94. None.
  95. .SH RATIONALE
  96. The related function
  97. \fIsetgroups\fR()
  98. is a privileged operation and therefore is not covered by this volume of POSIX.1\(hy2017.
  99. .P
  100. As implied by the definition of supplementary groups, the effective
  101. group ID
  102. may appear in the array returned by
  103. \fIgetgroups\fR()
  104. or it may be returned only by
  105. \fIgetegid\fR().
  106. Duplication may exist, but the application needs to call
  107. \fIgetegid\fR()
  108. to be sure of getting all of the information. Various implementation
  109. variations and administrative sequences cause the set of groups
  110. appearing in the result of
  111. \fIgetgroups\fR()
  112. to vary in order and as to whether the effective group ID is included,
  113. even when the set of groups is the same (in the mathematical sense of
  114. ``set''). (The history of a process and its parents could affect the
  115. details of the result.)
  116. .P
  117. Application developers should note that
  118. {NGROUPS_MAX}
  119. is not necessarily a constant on all implementations.
  120. .SH "FUTURE DIRECTIONS"
  121. None.
  122. .SH "SEE ALSO"
  123. .IR "\fIgetegid\fR\^(\|)",
  124. .IR "\fIsetgid\fR\^(\|)"
  125. .P
  126. The Base Definitions volume of POSIX.1\(hy2017,
  127. .IR "\fB<sys_types.h>\fP",
  128. .IR "\fB<unistd.h>\fP"
  129. .\"
  130. .SH COPYRIGHT
  131. Portions of this text are reprinted and reproduced in electronic form
  132. from IEEE Std 1003.1-2017, Standard for Information Technology
  133. -- Portable Operating System Interface (POSIX), The Open Group Base
  134. Specifications Issue 7, 2018 Edition,
  135. Copyright (C) 2018 by the Institute of
  136. Electrical and Electronics Engineers, Inc and The Open Group.
  137. In the event of any discrepancy between this version and the original IEEE and
  138. The Open Group Standard, the original IEEE and The Open Group Standard
  139. is the referee document. The original Standard can be obtained online at
  140. http://www.opengroup.org/unix/online.html .
  141. .PP
  142. Any typographical or formatting errors that appear
  143. in this page are most likely
  144. to have been introduced during the conversion of the source files to
  145. man page format. To report such errors, see
  146. https://www.kernel.org/doc/man-pages/reporting_bugs.html .