--- gdm-2.30.5/daemon/gdm-welcome-session.c.orig 2010-09-27 17:52:15.025543154 +0800 +++ gdm-2.30.5/daemon/gdm-welcome-session.c 2010-09-27 17:52:09.623508277 +0800 @@ -371,7 +371,7 @@ "LANG", "LANGUAGE", "LC_CTYPE", "LC_NUMERIC", "LC_TIME", "LC_COLLATE", "LC_MONETARY", "LC_MESSAGES", "LC_PAPER", "LC_NAME", "LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT", - "LC_IDENTIFICATION", "LC_ALL", + "LC_IDENTIFICATION", "LC_ALL", "AUDIODEV", NULL }; int i; @@ -891,6 +891,35 @@ /* FIXME: */ } + if (g_str_equal (welcome_session->priv->x11_display_device, "/dev/dtlocal") && g_file_test ("/opt/SUNWut/bin/utaudio", G_FILE_TEST_IS_EXECUTABLE)) { + char *out; + int status; + gboolean res; + GError *error; + + g_debug ("Running utaudio to get AUDIODEV"); + + res = g_spawn_command_line_sync ("/opt/SUNWut/bin/utaudio", + &out, + NULL, + &status, + &error); + if (! res) { + g_warning ("Could not run utaudio: %s", error->message); + g_error_free (error); + g_free (out); + } else { + out = g_strstrip (out); + if (g_file_test (out, G_FILE_TEST_EXISTS)) { + if (out && out[0] != '\0') { + g_setenv ("AUDIODEV", out, TRUE); + } + } + else + g_warning ("The audio device file %s doesn't exist", out); + } + } + env = get_welcome_environment (welcome_session); error = NULL; @@ -899,6 +928,67 @@ log_path = g_build_filename (LOGDIR, log_file, NULL); g_free (log_file); +#if __sun + /* + * Set ACL if running on the console or dtlocal. In this case, we know that + * logindevperm will be called on authentication, which will reste the device + * permissions. So there is no need to worry about checking if the ACL is + * already set, or appending the same ACL to the file. + */ + if (welcome_session->priv->x11_display_device) { + char *audiodev; + char *display_device; + + audiodev = g_strdup (g_getenv ("AUDIODEV")); + + if (g_str_has_prefix (welcome_session->priv->x11_display_device, "/dev/vt") + && g_str_equal (welcome_session->priv->x11_display_name, ":0")) { + display_device = g_strdup ("/dev/console"); + } else { + display_device = g_strdup (welcome_session->priv->x11_display_device); + } + + if (g_str_equal (display_device, "/dev/console") + && g_file_test ("/dev/audio", G_FILE_TEST_EXISTS)) { + int acl_flavor; + + acl_flavor = pathconf("/dev/audio", _PC_ACL_ENABLED); + + if (acl_flavor & _ACL_ACLENT_ENABLED) { + g_debug ("Setting device permissions: ACLIENT"); + system ("/usr/bin/setfacl -m user:gdm:rwx,mask:rwx /dev/audio"); + system ("/usr/bin/setfacl -m user:gdm:rwx,mask:rwx /dev/audioctl"); + } else if (acl_flavor & _ACL_ACE_ENABLED) { + g_debug ("Setting device permissions: ACE"); + system ("/usr/bin/chmod A+user:gdm:rwx:allow /dev/audio"); + system ("/usr/bin/chmod A+user:gdm:rwx:allow /dev/audioctl"); + } else { + g_debug ("Not setting device permissions: ACE"); + } + + } else if (g_str_equal (display_device, "/dev/dtlocal") + && (audiodev != NULL) + && (audiodev[0] != '\0') + && g_file_test (audiodev, G_FILE_TEST_EXISTS)) { + + char *tmp_cmd; + + g_debug ("Changing ownership for %s", audiodev); + tmp_cmd = g_strdup_printf ("/usr/bin/chown gdm %s", audiodev); + system (tmp_cmd); + g_free (tmp_cmd); + g_debug ("Changing ownership for %sctl", audiodev); + tmp_cmd = g_strdup_printf ("/usr/bin/chown gdm %sctl", audiodev); + system (tmp_cmd); + g_free (tmp_cmd); + } + + g_unsetenv ("AUDIODEV"); + g_free (display_device); + g_free (audiodev); + } +#endif + ret = spawn_command_line_async_as_user (welcome_session->priv->command, welcome_session->priv->user_name, welcome_session->priv->group_name,