summaryrefslogtreecommitdiff
path: root/libpamc
diff options
context:
space:
mode:
authorTBK <tbk@jjtc.eu>2020-02-26 00:24:39 +0100
committerTomáš Mráz <t8m@users.noreply.github.com>2020-02-26 08:16:18 +0100
commit5956cf525bfb53ed0c5cade3b58f18fde4f85c42 (patch)
tree797b3ef5e01ac77e186b3906501339b094dbfe7e /libpamc
parent8bd03a7dd02399cca16a4593018ab6e8d03a2ff9 (diff)
libpamc: Use ISO C99 uintX_t types instead of u_intX_t
u_intX_t is a glibcism this fixes the issue of compiling against musl libc.
Diffstat (limited to 'libpamc')
-rw-r--r--libpamc/include/security/pam_client.h21
-rw-r--r--libpamc/libpamc.h1
-rw-r--r--libpamc/pamc_converse.c8
-rw-r--r--libpamc/test/regress/test.libpamc.c3
4 files changed, 18 insertions, 15 deletions
diff --git a/libpamc/include/security/pam_client.h b/libpamc/include/security/pam_client.h
index 86672a2e..41f83da6 100644
--- a/libpamc/include/security/pam_client.h
+++ b/libpamc/include/security/pam_client.h
@@ -16,6 +16,7 @@ extern "C" {
#include <unistd.h>
#include <string.h>
#include <stdio.h>
+#include <stdint.h>
#include <sys/types.h>
/* opaque agent handling structure */
@@ -23,7 +24,7 @@ extern "C" {
typedef struct pamc_handle_s *pamc_handle_t;
/* binary prompt structure pointer */
-typedef struct { u_int32_t length; u_int8_t control; } *pamc_bp_t;
+typedef struct { uint32_t length; uint8_t control; } *pamc_bp_t;
/*
* functions provided by libpamc
@@ -90,10 +91,10 @@ char **pamc_list_agents(pamc_handle_t pch);
# define PAM_BP_FREE free
#endif /* PAM_BP_FREE */
-#define __PAM_BP_WOCTET(x,y) (*((y) + (u_int8_t *)(x)))
-#define __PAM_BP_ROCTET(x,y) (*((y) + (const u_int8_t *)(x)))
+#define __PAM_BP_WOCTET(x,y) (*((y) + (uint8_t *)(x)))
+#define __PAM_BP_ROCTET(x,y) (*((y) + (const uint8_t *)(x)))
-#define PAM_BP_MIN_SIZE (sizeof(u_int32_t) + sizeof(u_int8_t))
+#define PAM_BP_MIN_SIZE (sizeof(uint32_t) + sizeof(uint8_t))
#define PAM_BP_MAX_LENGTH 0x20000 /* an advisory limit */
#define PAM_BP_WCONTROL(x) (__PAM_BP_WOCTET(x,4))
#define PAM_BP_RCONTROL(x) (__PAM_BP_ROCTET(x,4))
@@ -102,8 +103,8 @@ char **pamc_list_agents(pamc_handle_t pch);
(__PAM_BP_ROCTET(x,2)<< 8)+ \
(__PAM_BP_ROCTET(x,3) ))
#define PAM_BP_LENGTH(x) (PAM_BP_SIZE(x) - PAM_BP_MIN_SIZE)
-#define PAM_BP_WDATA(x) (PAM_BP_MIN_SIZE + (u_int8_t *) (x))
-#define PAM_BP_RDATA(x) (PAM_BP_MIN_SIZE + (const u_int8_t *) (x))
+#define PAM_BP_WDATA(x) (PAM_BP_MIN_SIZE + (uint8_t *) (x))
+#define PAM_BP_RDATA(x) (PAM_BP_MIN_SIZE + (const uint8_t *) (x))
/* Note, this macro always '\0' terminates renewed packets */
@@ -111,13 +112,13 @@ char **pamc_list_agents(pamc_handle_t pch);
do { \
if ((old_p) != NULL) { \
if (*(old_p)) { \
- u_int32_t __size; \
+ uint32_t __size; \
__size = PAM_BP_SIZE(*(old_p)); \
memset(*(old_p), 0, __size); \
PAM_BP_FREE(*(old_p)); \
} \
if (cntrl) { \
- u_int32_t __size; \
+ uint32_t __size; \
\
__size = PAM_BP_MIN_SIZE + data_length; \
if ((*(old_p) = PAM_BP_CALLOC(1, 1+__size))) { \
@@ -140,7 +141,7 @@ do { \
#define PAM_BP_FILL(prmpt, offset, length, data) \
do { \
size_t bp_length; \
- u_int8_t *prompt = (u_int8_t *) (prmpt); \
+ uint8_t *prompt = (uint8_t *) (prmpt); \
bp_length = PAM_BP_LENGTH(prompt); \
if (bp_length < ((length)+(offset))) { \
PAM_BP_ASSERT("attempt to write over end of prompt"); \
@@ -151,7 +152,7 @@ do { \
#define PAM_BP_EXTRACT(prmpt, offset, length, data) \
do { \
size_t __bp_length; \
- const u_int8_t *__prompt = (const u_int8_t *) (prmpt); \
+ const uint8_t *__prompt = (const uint8_t *) (prmpt); \
__bp_length = PAM_BP_LENGTH(__prompt); \
if (((offset) < 0) || (__bp_length < ((length)+(offset))) \
|| ((length) < 0)) { \
diff --git a/libpamc/libpamc.h b/libpamc/libpamc.h
index 93c833c6..a22f52ea 100644
--- a/libpamc/libpamc.h
+++ b/libpamc/libpamc.h
@@ -16,6 +16,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <sys/wait.h>
+#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
diff --git a/libpamc/pamc_converse.c b/libpamc/pamc_converse.c
index bb9c6dfd..f8f60edf 100644
--- a/libpamc/pamc_converse.c
+++ b/libpamc/pamc_converse.c
@@ -34,8 +34,8 @@ static int __pamc_select_agent(pamc_handle_t pch, char *agent_id)
int pamc_converse(pamc_handle_t pch, pamc_bp_t *prompt_p)
{
- u_int32_t size, offset=0;
- u_int8_t control, raw[PAM_BP_MIN_SIZE];
+ uint32_t size, offset=0;
+ uint8_t control, raw[PAM_BP_MIN_SIZE];
D(("called"));
@@ -110,7 +110,7 @@ int pamc_converse(pamc_handle_t pch, pamc_bp_t *prompt_p)
/* pump all of the prompt into the agent */
do {
int rval = write(pch->current->writer,
- offset + (const u_int8_t *) (*prompt_p),
+ offset + (const uint8_t *) (*prompt_p),
size - offset);
if (rval == -1) {
switch (errno) {
@@ -172,7 +172,7 @@ int pamc_converse(pamc_handle_t pch, pamc_bp_t *prompt_p)
value from the previous loop */
while (offset < size) {
- int rval = read(pch->current->reader, offset + (u_int8_t *) *prompt_p,
+ int rval = read(pch->current->reader, offset + (uint8_t *) *prompt_p,
size-offset);
if (rval == -1) {
diff --git a/libpamc/test/regress/test.libpamc.c b/libpamc/test/regress/test.libpamc.c
index b0fff9c6..4251b4fa 100644
--- a/libpamc/test/regress/test.libpamc.c
+++ b/libpamc/test/regress/test.libpamc.c
@@ -5,6 +5,7 @@
*/
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#include <security/pam_client.h>
#include <ctype.h>
@@ -157,7 +158,7 @@ char *create_digest(int length, const char *raw)
return temp_packet.buffer;
}
-void packet_to_prompt(pamc_bp_t *prompt_p, u_int8_t control,
+void packet_to_prompt(pamc_bp_t *prompt_p, uint8_t control,
struct internal_packet *packet)
{
PAM_BP_RENEW(prompt_p, control, packet->at);