(was local bug #32304)
* Add fix for Redhat bug #573346: last incorrectly displays IPv6
addresses (was local bug #29497)
git-svn-id: svn://svn.sv.gnu.org/sysvinit/sysvinit/trunk@98
456724a4-4300-0410-8514-
c89748c515a2
sysvinit (2.89dsf) UNRELEASED; urgency=low
[ Werner Fink ]
sysvinit (2.89dsf) UNRELEASED; urgency=low
[ Werner Fink ]
+ * Fix signal and alarm handling based on the patch from Florent Viard.
+ (was local bug #32304)
+ * Add fix for Redhat bug #573346: last incorrectly displays IPv6
+ addresses (was local bug #29497)
* Correct fix for Debian bug #547073: use IUTF8 flag if defined
and if already set to make sure the utf-8 flag is not cleared
from the tty. Patch from Samuel Thibault.
* Correct fix for Debian bug #547073: use IUTF8 flag if defined
and if already set to make sure the utf-8 flag is not cleared
from the tty. Patch from Samuel Thibault.
struct sockaddr_in6 sin6;
struct sockaddr *sa;
int salen, flags;
struct sockaddr_in6 sin6;
struct sockaddr *sa;
int salen, flags;
- unsigned int topnibble;
- unsigned int azero = 0, sitelocal = 0;
int mapped = 0;
flags = useip ? NI_NUMERICHOST : 0;
/*
int mapped = 0;
flags = useip ? NI_NUMERICHOST : 0;
/*
- * IPv4 or IPv6 ? We use 2 heuristics:
- * 1. Current IPv6 range uses 2000-3fff or fec0-feff.
- * Outside of that is illegal and must be IPv4.
- * 2. If last 3 bytes are 0, must be IPv4
- * 3. If IPv6 in IPv4, handle as IPv4
+ * IPv4 or IPv6 ?
+ * 1. If last 3 4bytes are 0, must be IPv4
+ * 2. If IPv6 in IPv4, handle as IPv4
+ * 3. Anything else is IPv6
*
* Ugly.
*/
if (a[0] == 0 && a[1] == 0 && a[2] == (int32_t)htonl (0xffff))
mapped = 1;
*
* Ugly.
*/
if (a[0] == 0 && a[1] == 0 && a[2] == (int32_t)htonl (0xffff))
mapped = 1;
- topnibble = ntohl((unsigned int)a[0]) >> 28;
- azero = ntohl((unsigned int)a[0]) >> 16;
- sitelocal = (azero >= 0xfec0 && azero <= 0xfeff) ? 1 : 0;
-
- if (((topnibble < 2 || topnibble > 3) && (!sitelocal)) || mapped ||
- (a[1] == 0 && a[2] == 0 && a[3] == 0)) {
+ if (mapped || (a[1] == 0 && a[2] == 0 && a[3] == 0)) {
/* IPv4 */
sin.sin_family = AF_INET;
sin.sin_port = 0;
/* IPv4 */
sin.sin_family = AF_INET;
sin.sin_port = 0;
static void (*saved_sigtstp) = SIG_DFL;
static void (*saved_sigquit) = SIG_DFL;
static void (*saved_sigtstp) = SIG_DFL;
static void (*saved_sigquit) = SIG_DFL;
+static volatile sig_atomic_t alarm_rised;
+
#ifndef IUCLC
# define IUCLC 0
#endif
#ifndef IUCLC
# define IUCLC 0
#endif
void alrm_handler(int sig)
# endif
{
void alrm_handler(int sig)
# endif
{
+ /* Timeout expired */
+ alarm_rised++;
+
+ signal(SIGINT, saved_sigint);
+ signal(SIGTSTP, saved_sigtstp);
+ signal(SIGQUIT, saved_sigquit);
+
+ /* Never use exit(3) or stdio(3) within a signal handler */
* See if we need to open an other tty device.
*/
saved_sigint = signal(SIGINT, SIG_IGN);
* See if we need to open an other tty device.
*/
saved_sigint = signal(SIGINT, SIG_IGN);
- saved_sigtstp = signal(SIGQUIT, SIG_IGN);
- saved_sigquit = signal(SIGTSTP, SIG_IGN);
+ saved_sigquit = signal(SIGQUIT, SIG_IGN);
+ saved_sigtstp = signal(SIGTSTP, SIG_IGN);
if (optind < argc) tty = argv[optind];
if (tty || (tty = getenv("CONSOLE"))) {
if (optind < argc) tty = argv[optind];
if (tty || (tty = getenv("CONSOLE"))) {
* Ask for the password.
*/
while(pwd) {
* Ask for the password.
*/
while(pwd) {
if ((p = getpasswd(pwd->pw_passwd)) == NULL) break;
if (pwd->pw_passwd[0] == 0 ||
if ((p = getpasswd(pwd->pw_passwd)) == NULL) break;
if (pwd->pw_passwd[0] == 0 ||
- strcmp(crypt(p, pwd->pw_passwd), pwd->pw_passwd) == 0)
+ strcmp(crypt(p, pwd->pw_passwd), pwd->pw_passwd) == 0) {
- saved_sigquit = signal(SIGQUIT, SIG_IGN);
- saved_sigtstp = signal(SIGTSTP, SIG_IGN);
- saved_sigint = signal(SIGINT, SIG_IGN);
- printf("Login incorrect.\n");
+ failed++;
+ }
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGTSTP, SIG_IGN);
+ signal(SIGINT, SIG_IGN);
+ if (failed) {
+ printf("Can not execute su shell.\n");
+ break;
+ } else
+ printf("Login incorrect.\n");
+ if (alarm_rised)
+ printf("Timed out.\n");
+
- * User pressed Control-D.
+ * User may pressed Control-D.