Skip to content

Commit

Permalink
Fix compile on Alpine Linux when using fortified headers
Browse files Browse the repository at this point in the history
This commit removes obsolete compatibility code that was causing
compilation errors on Alpine Linux when the fortify-headers package is
installed. In short, the readlink, symlink and realpath compatibility
functions in src/lib/libast/comp don't work with Alpine Linux's
fortified headers. None of these functions are necessary to compile on
current operating systems (tested on Linux with glibc and musl,
{Free,Net,Open,DragonFly}BSD, illumos, Haiku and Cygwin) so these can be
safely deleted. Additionally, some spurious macro hackery relating to
strlcpy, strlcat and networking functions used in libcmd uname has also
been deleted. (The patch to univlib.h is taken from
ksh93#743 (comment).)

Co-authored-by: xorrvin <[email protected]>
  • Loading branch information
JohnoKing and xorrvin committed Apr 17, 2024
1 parent 2e8aeee commit edff13a
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 256 deletions.
10 changes: 0 additions & 10 deletions src/cmd/ksh93/features/poll
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,13 @@ tst socketpair_shutdown_mode note{ fchmod() after socketpair() shutdown() }end e
}
}end
cat{
#if _lib_poll
# define poll _SYS_poll
#else
# undef _hdr_poll
# undef _sys_poll
#endif /* _lib_poll */
#if _hdr_poll
# include <poll.h>
#else
# if _sys_poll
# include <sys/poll.h>
# endif /* _sys_poll */
#endif /* _hdr_poll */
#if _lib_poll
# undef poll
extern int poll(struct pollfd*,unsigned long,int);
#endif /* _lib_poll */
#if _lib_select
# ifndef FD_ZERO
# define FD_ZERO(x) (*(x)=0)
Expand Down
26 changes: 0 additions & 26 deletions src/lib/libast/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -2746,24 +2746,6 @@ make install virtual
exec - compile ${<}
done

make readlink.o
make comp/readlink.c
prev include/error.h
prev comp/fakelink.h implicit
prev include/ast.h
done
exec - compile ${<}
done

make symlink.o
make comp/symlink.c
prev include/error.h
prev comp/fakelink.h
prev include/ast.h
done
exec - compile ${<}
done

make getpgrp.o
make comp/getpgrp.c
prev include/ast_std.h
Expand Down Expand Up @@ -3103,14 +3085,6 @@ make install virtual
exec - compile ${<}
done

make realpath.o
make comp/realpath.c
prev ast_map.h
prev include/ast.h
done
exec - compile ${<}
done

make regcmp.o
make comp/regcmp.c
prev align.h
Expand Down
30 changes: 0 additions & 30 deletions src/lib/libast/comp/fakelink.h

This file was deleted.

53 changes: 0 additions & 53 deletions src/lib/libast/comp/readlink.c

This file was deleted.

46 changes: 0 additions & 46 deletions src/lib/libast/comp/realpath.c

This file was deleted.

51 changes: 0 additions & 51 deletions src/lib/libast/comp/symlink.c

This file was deleted.

3 changes: 0 additions & 3 deletions src/lib/libast/features/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ main(void)
printf("#define re_comp _ast_re_comp\n");
printf("#undef re_exec\n");
printf("#define re_exec _ast_re_exec\n");
printf("#undef realpath\n");
printf("#define realpath _ast_realpath\n");
printf("extern char* realpath(const char*, char*);\n");
#endif
/* Override the native regex library in favor of libast's regex functions */
printf("#undef regaddclass\n");
Expand Down
6 changes: 0 additions & 6 deletions src/lib/libast/misc/univlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
#define _UNIVLIB_H

#define getuniverse ______getuniverse
#define readlink ______readlink
#define setuniverse ______setuniverse
#define symlink ______symlink
#define universe ______universe

#include <ast.h>
Expand All @@ -49,9 +47,7 @@
#endif

#undef getuniverse
#undef readlink
#undef setuniverse
#undef symlink
#undef universe

#if _cmd_universe
Expand All @@ -73,9 +69,7 @@ extern char univ_env[];
#endif

extern int getuniverse(char*);
extern int readlink(const char*, char*, int);
extern int setuniverse(int);
extern int symlink(const char*, const char*);
extern int universe(int);

#endif
4 changes: 0 additions & 4 deletions src/lib/libast/string/strlcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
* strlcat implementation
*/

#define strlcat ______strlcat

#include <ast.h>

#undef strlcat

#undef _def_map_ast
#include <ast_map.h>

Expand Down
4 changes: 0 additions & 4 deletions src/lib/libast/string/strlcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
* strlcpy implementation
*/

#define strlcpy ______strlcpy

#include <ast.h>

#undef strlcpy

#undef _def_map_ast
#include <ast_map.h>

Expand Down
23 changes: 0 additions & 23 deletions src/lib/libcmd/uname.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ static const char usage[] =
" \bsysconf\b(3), \bsysinfo\b(2)]"
;

#define getdomainname ______getdomainname
#define gethostid ______gethostid
#define gethostname ______gethostname
#define sethostname ______sethostname

#include <cmd.h>
#include <ctype.h>
#include <stdio.h>
Expand All @@ -84,24 +79,6 @@ static const char usage[] =
# include <sys/utsname.h>
#endif

#undef getdomainname
#undef gethostid
#undef gethostname
#undef sethostname

#if _lib_getdomainname
extern int getdomainname(char*, size_t);
#endif
#if _lib_gethostid
extern long gethostid(void);
#endif
#if _lib_gethostname
extern int gethostname(char*, size_t);
#endif
#if _lib_sethostname
extern int sethostname(const char*, size_t);
#endif

#ifndef HOSTTYPE
#define HOSTTYPE "unknown"
#endif
Expand Down

0 comments on commit edff13a

Please sign in to comment.