--- sound-juicer-2.32.0/src/sj-main.c.~4~ 2016-03-11 19:21:47.745036823 +0300 +++ sound-juicer-2.32.0/src/sj-main.c 2016-03-11 22:54:52.065426719 +0300 @@ -49,6 +49,10 @@ #include "sj-play.h" #include "sj-genres.h" +#ifdef __sun +#include +#endif + gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); static void reread_cd (gboolean ignore_no_media); @@ -1606,6 +1610,40 @@ } } +#ifdef __sun +static int setprivs(){ + priv_set_t *pPrivSet; + + if(geteuid()==0){ + g_warning("Running with euid 0, assuming you know what you are doing"); + return 0; + } + + if ((pPrivSet = priv_allocset()) == NULL) { + return 1; + } + + priv_basicset(pPrivSet); + + if(priv_addset(pPrivSet,PRIV_SYS_DEVICES)) { + return 2; + }; + + if(setppriv(PRIV_SET,PRIV_EFFECTIVE,pPrivSet)) { + return 3; + } + + /* CLI tools should also be able to use USCSICMD ioctls */ + if(setppriv(PRIV_SET,PRIV_INHERITABLE,pPrivSet)) { + return 4; + } + + priv_freeset(pPrivSet); + + return 0; +} +#endif + int main (int argc, char **argv) { GError *error = NULL; @@ -1619,9 +1657,18 @@ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &uris, N_("URI to the CD device to read"), NULL }, { NULL } }; +#ifdef __sun + int pcode=0; +#endif if (!g_thread_supported ()) g_thread_init (NULL); +#ifdef __sun + if (pcode=setprivs()){ + g_warning("Couldn't raise privileges, pcode=%d\n",pcode); + } +#endif + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE);