Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 372675
Collapse All | Expand All

(-)qingy-1.0.0.orig//src/libraries/session.c (-20 / +107 lines)
Lines 440-447 int check_password(char *username, char Link Here
440
  char *password;
440
  char *password;
441
#ifdef USE_PAM
441
#ifdef USE_PAM
442
  int retcode;
442
  int retcode;
443
  char *ttyname;
444
  char *short_ttyname;
445
#else
443
#else
446
  char*  correct;
444
  char*  correct;
447
#ifdef HAVE_LIBCRYPT
445
#ifdef HAVE_LIBCRYPT
Lines 468-497 int check_password(char *username, char Link Here
468
	}
466
	}
469
  
467
  
470
#ifdef USE_PAM
468
#ifdef USE_PAM
469
  /* Setup of PAM_TTY have been moved to new func set_pam_tty_to_current_tty(). */
470
  /* Because current vt is not the vt that going to run session actual in mostly cases. */
471
  PAM_password = (char *)password;
471
  PAM_password = (char *)password;
472
  ttyname = create_tty_name(get_active_tty());
473
  if ((short_ttyname = strrchr(ttyname, '/')) != NULL)
474
	if (*(++short_ttyname) == '\0') short_ttyname = NULL;
475
  if (pam_start("qingy", username, &PAM_conversation, &pamh) != PAM_SUCCESS)
472
  if (pam_start("qingy", username, &PAM_conversation, &pamh) != PAM_SUCCESS)
476
	{
473
	{
477
		LogEvent(pw, PAM_FAILURE);
474
		LogEvent(pw, PAM_FAILURE);
478
		return 0;
475
		return 0;
479
	}
476
	}
480
	if (!short_ttyname)
481
		retcode = pam_set_item(pamh, PAM_TTY, ttyname);
482
	else
483
	{
484
		retcode = pam_set_item(pamh, PAM_TTY, short_ttyname);
485
		if (retcode != PAM_SUCCESS)
486
			retcode = pam_set_item(pamh, PAM_TTY, ttyname);
487
	}
488
  if (retcode != PAM_SUCCESS)
489
	{
490
		pam_end(pamh, retcode);
491
		pamh = NULL;
492
		LogEvent(pw, PAM_FAILURE);
493
		return 0;
494
	}
495
  if ((retcode = pam_set_item(pamh, PAM_RHOST, "")) != PAM_SUCCESS)
477
  if ((retcode = pam_set_item(pamh, PAM_RHOST, "")) != PAM_SUCCESS)
496
	{
478
	{
497
		pam_end(pamh, retcode);
479
		pam_end(pamh, retcode);
Lines 556-561 int check_password(char *username, char Link Here
556
#endif /* End of USE_PAM */
538
#endif /* End of USE_PAM */
557
}
539
}
558
540
541
#ifdef USE_PAM
542
int autologin_pam_start (char *username)
543
{
544
	struct passwd *pw;
545
546
	int retcode;
547
	
548
	pw = getpwnam(username);
549
	endpwent();
550
	if (!pw)
551
	{
552
		struct passwd pwd;
553
      
554
		pwd.pw_name = username;
555
		LogEvent(&pwd, UNKNOWN_USER);
556
		return 0;
557
	}
558
	if (pam_start("qingy", username, &PAM_conversation, &pamh) != PAM_SUCCESS)
559
	{
560
		return 0;
561
	}
562
	if ((retcode = pam_set_item(pamh, PAM_RHOST, "")) != PAM_SUCCESS)
563
	{
564
		pam_end(pamh, retcode);
565
		pamh = NULL;
566
		LogEvent(pw, PAM_FAILURE);
567
		return 0;
568
	}
569
	free (infostr); free (errstr);
570
	
571
	return 1;
572
}
573
#endif
574
559
static char *shell_base_name(char *name)
575
static char *shell_base_name(char *name)
560
{
576
{
561
  char *base = name;
577
  char *base = name;
Lines 795-800 void remove_utmp_entry(void) Link Here
795
	endutent ();
811
	endutent ();
796
}
812
}
797
813
814
#ifdef USE_PAM
815
/* Setting up PAM_TTY. */
816
/* and CKCON_X11_DISPLAY_DEVICE for graphical session. */
817
/* x_display == -1 means text session. */
818
int set_pam_tty_to_current_tty(int cur_tty, int x_display)
819
{
820
	int retcode;
821
	char *tty_for_pam;
822
	char *short_tty_for_pam;
823
	char *x11_display;
824
	char *x11_display_device;
825
	
826
	tty_for_pam = create_tty_name(cur_tty);
827
	if ((short_tty_for_pam = strrchr(tty_for_pam, '/')) != NULL)
828
		if (*(++short_tty_for_pam) == '\0') short_tty_for_pam = NULL;
829
830
	if ( x_display == -1 ) /* session is text session. */
831
	{
832
		if (!short_tty_for_pam)
833
		{
834
			retcode = pam_set_item(pamh, PAM_TTY, tty_for_pam);
835
		}
836
		else
837
		{
838
			retcode = pam_set_item(pamh, PAM_TTY, short_tty_for_pam);
839
			if (retcode != PAM_SUCCESS)
840
			{
841
				retcode = pam_set_item(pamh, PAM_TTY, tty_for_pam);
842
			}
843
		}
844
		if (retcode != PAM_SUCCESS)
845
		{
846
			WRITELOG (ERROR, "Something wrong with setting PAM_TTY to %s\n", tty_for_pam);
847
			return 0;
848
		}
849
	}
850
	else /* session is graphical. */
851
	{
852
		x11_display = StrApp ((char **)NULL, ":", int_to_str(x_display), (char*)NULL);
853
		retcode = pam_set_item (pamh, PAM_TTY, x11_display);
854
		if (retcode != PAM_SUCCESS)
855
		{
856
			WRITELOG (ERROR, "Something wrong with setting PAM_TTY to %s\n", x11_display);
857
			return 0;
858
		}
859
		x11_display_device = StrApp ((char**)NULL, "CKCON_X11_DISPLAY_DEVICE=", tty_for_pam, (char*)NULL);
860
		pam_putenv (pamh, x11_display_device);
861
		if (retcode != PAM_SUCCESS)
862
		{
863
			writelog (ERROR, "Setting CKCON_X11_DISPLAY_DEVICE failed.\n");
864
			return 0;
865
		}
866
		
867
	}
868
	free (infostr); free (errstr);
869
870
	return 1;
871
}
872
#endif
873
798
void Text_Login(struct passwd *pw, char *session, char *username)
874
void Text_Login(struct passwd *pw, char *session, char *username)
799
{
875
{
800
  pid_t proc_id;
876
  pid_t proc_id;
Lines 824-829 void Text_Login(struct passwd *pw, char Link Here
824
			WRITELOG(DEBUG, "Starting text session with argument #%d: %s\n", i, args[i]);
900
			WRITELOG(DEBUG, "Starting text session with argument #%d: %s\n", i, args[i]);
825
901
826
#ifdef USE_PAM
902
#ifdef USE_PAM
903
	/* We set PAM_TTY to current_vt. */
904
	/* This is important for DirectFB GUI login screen. */
905
	/* DirectFB runs on unused tty. */
906
	/* But that tty is not the tty which we are going to start session for. */
907
	if(!set_pam_tty_to_current_tty(current_vt, -1))
908
	  writelog (ERROR, "Something wrong with pam_tty_set_to_current_tty(). But we keep going.\n");
827
		pam_open_session(pamh, 0);
909
		pam_open_session(pamh, 0);
828
#else
910
#else
829
		LogEvent(pw, OPEN_SESSION);
911
		LogEvent(pw, OPEN_SESSION);
Lines 1016-1022 void Graph_Login(struct passwd *pw, char Link Here
1016
  free(vt);
1098
  free(vt);
1017
1099
1018
#ifdef USE_PAM
1100
#ifdef USE_PAM
1101
  /* At graphical session, PAM_TTY is set to $DISPLAY. */
1102
  /* and CKCON_X11_DISPLAY_DEVICE(needed by pam_ck_connector.so) is set to proper tty. */
1103
  if(!set_pam_tty_to_current_tty(x_vt, x_offset))
1104
	  writelog (ERROR, "Something wrong with setting PAM_TTY and CKCON_X11_DISPLAY_DEVICE. But we keep going.\n");
1019
		pam_open_session(pamh, 0);
1105
		pam_open_session(pamh, 0);
1106
  pam_putenv(pamh, "CKCON_X11_DISPLAY_DEVICE");
1020
#else
1107
#else
1021
		LogEvent(pw, OPEN_SESSION);
1108
		LogEvent(pw, OPEN_SESSION);
1022
#endif
1109
#endif
(-)qingy-1.0.0.orig//src/libraries/session.h (+3 lines)
Lines 41-43 void start_session(char *username, char Link Here
41
41
42
/* sort sessions */
42
/* sort sessions */
43
void sort_sessions(char **sessions, int n_items);
43
void sort_sessions(char **sessions, int n_items);
44
45
/* PAM initialization for autologin */
46
int autologin_pam_start(char *username);
(-)qingy-1.0.0.orig//src/main.c (+10 lines)
Lines 356-361 void start_up(int argc, char *argv[], in Link Here
356
	/* return to our righteous tty */
356
	/* return to our righteous tty */
357
	set_active_tty(our_tty_number);
357
	set_active_tty(our_tty_number);
358
358
359
#ifdef USE_PAM
360
	/* PAM initialization for autologin. */
361
	if (do_autologin)
362
	{
363
		if (!autologin_pam_start(username))
364
			/* Keep going. */
365
			writelog (ERROR, "autologin pam initialization failed.\n");
366
	}
367
#endif
368
	
359
	switch (returnstatus)
369
	switch (returnstatus)
360
	{
370
	{
361
		case EXIT_SUCCESS:
371
		case EXIT_SUCCESS:

Return to bug 372675