Difference between revisions of "User:Tomato"

From ArchWiki
Jump to: navigation, search
(Modifying fileshareset scripts)
Line 4: Line 4:
 
Sadly, this functionality is implemented using SUID perl script, and as Archlinux does not support SUID scripts nor it has perl-suid package we will have to get our hands dirty.
 
Sadly, this functionality is implemented using SUID perl script, and as Archlinux does not support SUID scripts nor it has perl-suid package we will have to get our hands dirty.
  
{{Note|Works with simple file sharing only at the moment}}
+
{{Note|Works with simple file sharing only at the moment, advanced file sharing still asks for root password}}
  
 
Work plan:
 
Work plan:
Line 20: Line 20:
 
* {{Package Official|kdebase-runtime}} basic KDE workspace (but if you're reading this, chances are you already have it installed)
 
* {{Package Official|kdebase-runtime}} basic KDE workspace (but if you're reading this, chances are you already have it installed)
 
* {{Package Official|kdelibs3}} for {{Codeline|fileshareset}} (not sure about it, but as of KDE4.4.0 it's still a dependency)
 
* {{Package Official|kdelibs3}} for {{Codeline|fileshareset}} (not sure about it, but as of KDE4.4.0 it's still a dependency)
 +
* {{Package Official|gcc}} to compile SUID wrapper
  
 
==== Installing requisites ====
 
==== Installing requisites ====
Line 53: Line 54:
 
   ln -s fileshareset.pl filesharelist
 
   ln -s fileshareset.pl filesharelist
 
done}}
 
done}}
 +
 +
==== Create C wrapper ====
 +
Create such files in your home directory:
 +
 +
{{File|name=kde4.c|content=#include <stdio.h>
 +
#include <stdlib.h>
 +
#include <string.h>
 +
#include <sys/types.h>
 +
#include <unistd.h>
 +
 +
#define EXEC "/usr/lib/kde4/libexec/fileshareset.pl"
 +
 +
int
 +
main(int argc, char** argv)
 +
{
 +
  char **args;
 +
 +
  setegid(0);
 +
  seteuid(0);
 +
  setgid(0);
 +
  setuid(0);
 +
 +
  args = calloc(argc+1, sizeof(char**));
 +
  if (args == 0)
 +
    exit(1);
 +
 +
  for (int i=0; i < argc; i++)
 +
  {
 +
    args[i] = calloc(1,strlen(argv[i]));
 +
    if(args[i] == 0)
 +
      exit(1);
 +
    strcpy(args[i], argv[i]);
 +
  }
 +
  return execv(EXEC, args);
 +
}
 +
}}
 +
 +
{{File|name=kde3.c|content=#include <stdio.h>
 +
#include <stdlib.h>
 +
#include <string.h>
 +
#include <sys/types.h>
 +
#include <unistd.h>
 +
 +
#define EXEC "/opt/kde/bin/fileshareset.pl"
 +
 +
int
 +
main(int argc, char** argv)
 +
{
 +
  char **args;
 +
 +
  setegid(0);
 +
  seteuid(0);
 +
  setgid(0);
 +
  setuid(0);
 +
 +
  args = calloc(argc+1, sizeof(char**));
 +
  if (args == 0)
 +
    exit(1);
 +
 +
  for (int i=0; i < argc; i++)
 +
  {
 +
    args[i] = calloc(1,strlen(argv[i]));
 +
    if(args[i] == 0)
 +
      exit(1);
 +
    strcpy(args[i], argv[i]);
 +
  }
 +
  return execv(EXEC, args);
 +
}
 +
}}
 +
 +
compile them using <code>gcc kde4.c -std=c99 -o kde4</code> and <code>gcc kde3.c -std=c99 -o kde3</code>.
 +
Copy them to system folders:
 +
{{Command|name=copying wrappers|output=cp kde3 /opt/kde/bin/fileshareset
 +
chown root:root /opt/kde/bin/fileshareset
 +
chmod u+s /opt/kde/bin/fileshareset
 +
cp kde4 /usr/lib/kde4/libexec/fileshareset
 +
chown root:root /usr/lib/kde4/libexec/fileshareset
 +
chmod u+s /usr/lib/kde4/libexec/fileshareset
 +
}}
 +
  
 
magic:
 
magic:
 
kcmshell4 fileshare
 
kcmshell4 fileshare

Revision as of 00:26, 27 February 2010

just my personal scrapbook

Configure file sharing from KDE4 using samba

Sadly, this functionality is implemented using SUID perl script, and as Archlinux does not support SUID scripts nor it has perl-suid package we will have to get our hands dirty.

Note: Works with simple file sharing only at the moment, advanced file sharing still asks for root password

Work plan:

  1. install packages
  2. configure samba
  3. modify Template:Codeline scripts
  4. create C wrapper for Template:Codeline to work as a SUID binary
  5. configure KDE side of things
  6. share a folder

Packages we will need:

Installing requisites

Install all packages and their dependencies:

Template:Codeline

Log out and log in again (kdelibs3 are in non standard place and so the PATH must be updated)

Configuring samba

A basic config file works OK, though you'll need to create Samba users (with smbpasswd -a <user name> as root): Template:File

Remember to add samba to DAEMONS in /etc/rc.conf if you want it to start at boot time.

Modifying fileshareset scripts

Template:Command

Create C wrapper

Create such files in your home directory:

Template:File

Template:File

compile them using gcc kde4.c -std=c99 -o kde4 and gcc kde3.c -std=c99 -o kde3. Copy them to system folders: Template:Command


magic: kcmshell4 fileshare