Light-Debian-Core-Live-CD-Wheezy + Porteus-Wheezy

For talk and support relating specifically to Puppy derivatives
Message
Author
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#2081 Post by fredx181 »

Hi Toni
Thanks for the slim deb.
I found a better solution IMO
The key is :

Code: Select all

touch /etc/default/locale
Then whatever you want (I use "insserv -r slim" to disable slim service) like:
slim-stop:

Code: Select all

#!/bin/bash

[ "`whoami`" != "root" ] && exec gsu ${0}

insserv -r slim
cp -fr /etc/inittab-auto /etc/inittab
slim-start:

Code: Select all

#!/bin/bash

[ "`whoami`" != "root" ] && exec gsu ${0}

insserv slim
cp -fr /etc/inittab-noauto /etc/inittab
Fred

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2082 Post by mcewanw »

saintless wrote:Hi, William.

I need your help on this one. I remember you wrote you have some experience with XDM in the past.
XDM changes the PATH when is active and do not allow the system to read /etc/profile export lines. Not only for user but also for root.
I thought this is the only problem and adding the export lines from /etc/profile to /etc/environment will fix it. It did but it gives also secure bin paths for user account which is not right.
Unfortunately this is not the only problem. When XDM is active Synaptic does not work anymore with sudo.
Hi Toni, I haven't checked Synaptic yet, but I think the PATH for xdm sessions should be set in /etc/X11/xdm/xdm-config

So comment out your PATH line in /etc/environment and in xdm-config try adding immediately after:

Code: Select all

DisplayManager.willing:		su nobody -s /bin/sh -c /etc/X11/xdm/Xwilling
the following:

Code: Select all

DisplayManager*userPath: /opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
DisplayManager*systemPath: /opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin
and reboot. That seems to fix the PATH's appropriately for root and normal user for me.

There are lots of info about setting up xdm. For example, the PATH change above is mentioned near the beginning of chapter 9.1 XDM of the following downloadable pdf:

http://www.tldp.org/HOWTO/pdf/Path.pdf
github mcewanw

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#2083 Post by saintless »

Thank you, William!
I also found this pdf an hour ago and testing the same.
The path works on the top above this line also.

Code: Select all

DisplayManager.authDir:	/var/lib/xdm
And I read it is good to add /usr/bin/x11
I have this now as paths:

Code: Select all

DisplayManager*userPath: /opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/bin/x11
DisplayManager*systemPath: /opt/bin:/usr/local/bin:/usr/bin:/usr/bin/X11:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin"
The path works in but it does not solve the sudo issue with sinaptic.

Toni

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2084 Post by mcewanw »

Toni, I don't know if there is some trick for xdm configs to export DISPLAY and Xauthority, however:

Exporting DISPLAY and Xauthority environment variables followed by changing sudoers file to keep DISPLAY and Xauthority might do the trick per the links below, Tony. I am just going out so don't have time to test it:

http://blog.edwards-research.com/2012/0 ... with-sudo/

http://dev-loki.blogspot.co.nz/2009/01/using-sudo.html
First of all, edit /etc/sudoers (which one should always do using the command visudo as it validates the configuration before saving it) and allow the environment variables DISPLAY and XAUTHORITY to be forwarded when using sudo, by adding the following line:

Code: Select all

Defaults env_keep += "DISPLAY XAUTHORITY"
The second step is to set and export the environment variable XAUTHORITY. The simplest option is to add the following line to your ~/.bashrc or add it to /etc/bash.bashrc.local, the latter being for all users on your host:

Code: Select all

[ -n "$DISPLAY" -a -e "$HOME/.Xauthority" ] && export XAUTHORITY="$HOME/.Xauthority"
http://unix.stackexchange.com/questions ... forwarding

http://ubuntuforums.org/archive/index.p ... 52811.html
Last edited by mcewanw on Mon 31 Mar 2014, 03:08, edited 3 times in total.
github mcewanw

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2085 Post by mcewanw »

Yes, my above post about xdm and modify sudoers with visudo seems to work. Following the sudo config change, I had synaptic working from puppy user quicky via:

Code: Select all

puppy@debian:~$ export DISPLAY
puppy@debian:~$ export XAUTHORITY=".Xauthority"
puppy@debian:~$ sudo synaptic
Still, I imagine there 'might' be a variable in xdm configs that could set it all up automatically somehow. I just don't know what.

Further info in Section 9.4.12 onwards of:

http://qref.sourceforge.net/Debian/refe ... ne.en.html

THE ABOVE LINK LOOKS PARTICULARLY USEFUL. Provides an alternative trick to run sudo gui commands from normal user login:
9.4.12 Getting root in X

If a GUI program needs to be run with root privilege, use the following procedures to display program output on a user's X server. Never attempt to start an X server directly from the root account in order to avoid possible security risks.

Start the X server as a normal user and open an xterm console. Then:

$ XAUTHORITY=$HOME/.Xauthority
$ export XAUTHORITY
$ su root
Password:*****
# printtool &

When using this trick to su to a non-root user, make sure ~/.Xauthority is group readable by this non-root user.

To automate this command sequence, create a file ~/.xsession from the user's account, containing the following lines:

# This makes X work when I su to the root account.
if [ -z "$XAUTHORITY" ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi
unset XSTARTUP
# If a particular window/session manager is desired, uncomment
# the following and edit it to fit your needs.
#XSTARTUP=/usr/bin/blackbox
# This starts x-window/session-manager program
if [ -z "$XSTARTUP" ]; then
if [ -x /usr/bin/x-session-manager ]; then
XSTARTUP=x-session-manager
elif [ -x /usr/bin/x-window-manager ]; then
XSTARTUP=x-window-manager
elif [ -x /usr/bin/x-terminal-emulator ]; then
XSTARTUP=x-terminal-emulator
fi
fi
# execute auto selected X window/session manager
exec $XSTARTUP

Then run su (not su -) in an xterm window of the user. Now GUI programs started from this xterm can display output on this user's X window while running with root privilege. This trick works as long as the default /etc/X11/Xsession is executed. If a user set up his customization using ~/.xinitrc or ~/.xsession, the above mentioned environment variable XAUTHORITY needs to be set similarly in those scripts.

Alternatively, sudo can be used to automate the command sequence:

$ sudo xterm
... or
$ sudo -H -s

Here /root/.bashrc should contain:

if [ $SUDO_USER ]; then
sudo -H -u $SUDO_USER xauth extract - $DISPLAY | xauth merge -
fi

This works fine even with the home directory of the user on an NFS mount, because root does not read the .Xauthority file.

There are also several specialized packages for this purpose: kdesu, gksu, gksudo, gnome-sudo, and xsu. Some other methods can be used to achieve similar results: creating a symlink from /root/.Xauthority to the user's corresponding one; use of the script sux; or putting "xauth merge ~USER_RUNNING_X/.Xauthority" in the root initialization script.
So the following seems to work:

1. Don't bother altering /etc/sudoers. Instead:

2. Add the following code to the bottom of /root/.bashrc

Code: Select all

if [ $SUDO_USER ]; then
sudo -H -u $SUDO_USER xauth extract - $DISPLAY | xauth merge -
fi
3. And add the following to the beginning of both ~/startup=jwm and ~/startup-icewm (where ~ is home directory of normal user such as puppy):

Code: Select all

if [ -z "$XAUTHORITY" ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi
Then, when logged in as normal user, sudo 'command' seems able to open the GUI in the user's X display. I expect it works with su also.

EDIT: works using sudo from user's xterm anyway, but I seem to have missed something cos didn't work from JWM menu and I'm going out so can't test further just now.

I don't understand, Toni, how you were able to use su as a normal user and then run synaptics without this trick.
Last edited by mcewanw on Mon 31 Mar 2014, 03:54, edited 3 times in total.
github mcewanw

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2086 Post by sunburnt »

# Trying to detect USB device type, H.D., CD-DVD, Flash, SD, etc.
It seems impossible to do this. It`s even very hard to detect if sdxx is removable or not.
dmesg and /var/log/messages is only way to detect a USB event. Difficult to parse them.
What a horrible mess Linux/Unix is... Getting info is a scattered and sketchy affair.
# Trying to write a USB installer for DebDog. Looks like it`s going to be ultra simple.


# Toni; Fixed I believe. Odd that only the e3 menu file caused it.
Attachments
debmenu2desktop.convert.zip
(11.36 KiB) Downloaded 149 times

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2087 Post by sunburnt »

# Toni & Fred; Do we have a way to use a dir. for the live-rw.? How about a partition.?
I read that Fred had a live-rw dir. working in PorteusDog.

# If partition is just Deb/PorteusDog + live-rw dir., then the partition can be 1-2 GB in size.
And so a fsck of the partition is quick, and at the same time the O.S. files get checked too.

# Thinking of a USB setup like this:

| Windows FAT partition | Boot partition 1-2GB | Extra O.S. partitions 1-2GB | Swap |

Most USBs would only have 2 partitions, "Windows FAT", and "Boot + Deb-Live".
FAT for the main storage area is okay, it can hold anything except Linux files. Better than NTFS.
And FAT dosen`t care if it`s mounted while doing a fsck, making it easy to maintain.
Most USBs won`t have other O.S.s, and a swap file/partition on a Flash device is a bad idea.
If the PC is low on ram, then using a second "expendable" 1-2GB Flash drive is a good solution.
I`m guessing a "swap" Flash drive will last about 6 months of normal daily use. So a cheap one...
Sadly buying more ram for old PCs is just a bad idea, DDR-3 costs less than older ram does.
.

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#2088 Post by saintless »

mcewanw wrote:Further info in Section 9.4.12 onwards of:

http://qref.sourceforge.net/Debian/refe ... ne.en.html

THE ABOVE LINK LOOKS PARTICULARLY USEFUL. Provides an alternative trick to run sudo gui commands from normal user login:
Thank you, William!
I will test this today.
I don't understand, Toni, how you were able to use su as a normal user and then run synaptics without this trick.
I see nothing strange since Debian Live Standard CD also doesn't need to use tricks like that. It has active user account and after installing X you get straight to X from login prompt. After sudo apt-get install synaptic all it needs is to type sudo synaptic and it starts. Nothing from your post above is needed.

The strange thing for me is XDM is the only Display manager that needs this operations to make Synaptic work.
LightDM and Slim does not need this to make Synaptic work for user.
EDIT: works using sudo from user's xterm anyway, but I seem to have missed something cos didn't work from JWM menu and I'm going out so can't test further just now.
The script which starts Synaptic from menu is /opt/bin/synaptic-start:

Code: Select all

#!/bin/bash

if [ "`whoami`" != "root" ]; then
xterm -e sudo synaptic
exit 0
fi

synaptic
It works for user when autologin is active and with LightDM and Slim without changing anything.
I guess the changes you posted make the user account to run direct the synaptic line in the script without sudo? Need to test this first to confirm.

Toni

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#2089 Post by saintless »

# Trying to write a USB installer for DebDog. Looks like it`s going to be ultra simple.


# Toni; Fixed I believe. Odd that only the e3 menu file caused it.
Thank you, Terry!
sunburnt wrote:# Toni & Fred; Do we have a way to use a dir. for the live-rw.? How about a partition.?
We can use folder only if DebianDog boots with porteus-boot-initrd. It will be available boot option in the beta iso version.
With debian live-boot which we use now and is default for DebianDog we can not use folder but we can use save partition. Haven't tested this myself but I think all we need is to make ext partition and label it live-rw.
# Thinking of a USB setup like this:

| Windows FAT partition | Boot partition 1-2GB | Extra O.S. partitions 1-2GB | Swap |
I also think SWAP partition on flash drive is not needed.
Terry, the structure of DebianDog beta iso will be this one:
http://smokey01.com/saintless/Light-Whe ... g-test.iso
It has two initrd files and more files and folders in /live
It is needed to make it boot both ways - debian and porteus.
What about if the flash drive is only 1Gb or less? Will it be possible to install DebianDog on smaller flash drive?
DebianDog beta iso will be around 110 Mb with porteus-initrd and debian-initrd included.

Toni

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2090 Post by sunburnt »

So I assume it`s a bit of code in Porteus initrd that does the alternate live-rw setup.

# Q... Will DebDog boot with Porteus initrd with Wheezy kernel.? Is there a Porteus kernel.?

I don`t know differences, but if Fred put up lots of effort, then the initrd has some advantages.
# Could make 2 partitions, 1 for DebDog and 1 for live-rw. But both in 1 has advantages.

Toni; Didn`t mention, if USB < 8GB, then 1 Linux partition. Why make small even smaller.?


# Here`s "drive-info", it`s for the USB installer.
You can see the USB removable "rem" drive:

Code: Select all

Part Type F/R Boot        Sizes            Drv.Label
=====================================================
sda1 ext3 fix boot 6.320-GiB 6786383872 
sda2 swap fix      1.953-GiB 2097152000 
sda3 ext3 fix      103.5-GiB 111148007424 
sdb1 vfat rem boot 7.216-GiB 7747895808 Red-8gb
# What a pain it was getting just this info., 5 different sources were needed.!
/proc/partitions, dmesg, disktype, fdisk, and blkid
The best part is that all this info can be gotten with the partition un-mounted.

# The parted tools can do all of this and make and manipulate partitions.

# Makes me think of having env variables to hold each line of this info.
$PART_SDA1, $PART_SDA3, $PART_SDB1, etc.
Then no files to read and very little parsing to get the needed info.
At the very least, we should have a system info. file to "source" to get info.

# I`ll post the whole installer when it`s ready.
# Please give a test try with USBs in & out and let me know...

### UPDATE: Now has "Boot" column added ( See output above )..
Attachments
drive-info.zip
Path: /opt/bin
(770 Bytes) Downloaded 140 times
Last edited by sunburnt on Mon 31 Mar 2014, 06:46, edited 6 times in total.

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2091 Post by mcewanw »

saintless wrote: The script which starts Synaptic from menu is /opt/bin/synaptic-start:

Code: Select all

#!/bin/bash

if [ "`whoami`" != "root" ]; then
xterm -e sudo synaptic
exit 0
fi

synaptic
It works for user when autologin is active and with LightDM and Slim without changing anything.
I guess the changes you posted make the user account to run direct the synaptic line in the script without sudo? Need to test this first to confirm.

Toni
Yes, I knew that was the script. I'm a bit confused about what the problem really is, but it works, if I also change the /opt/bin/synaptic-start script to:

Code: Select all

#!/bin/bash
if [ "`whoami`" != "root" ]; then
if [ -z "$XAUTHORITY" ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi
xterm -e sudo synaptic
exit 0
fi

synaptic
So it seems the XAUTHORITY env variable wasn't being exported to that shell for some reason......
github mcewanw

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2092 Post by mcewanw »

saintless wrote:
sunburnt wrote:# Toni & Fred; Do we have a way to use a dir. for the live-rw.?...
We can use folder only if DebianDog boots with porteus-boot-initrd
I'm actually using DebianDog with Porteus-boot-initrd (after Toni explained to me how to set up that method) so that I can use dir for persistence. I really really like that method because I can manually edit the persistence directory anytime and the changes reflect that editing thereafter. So I can quickly modify and whiteout files and so on and then simply delete the changes and get back to where I was. It's great!
github mcewanw

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2093 Post by mcewanw »

saintless wrote: The strange thing for me is XDM is the only Display manager that needs this operations to make Synaptic work.
LightDM and Slim does not need this to make Synaptic work for user.
Yet that link I gave earlier includes the quote:

http://qref.sourceforge.net/Debian/refe ... ne.en.html
9.4.12 Getting root in X

If a GUI program needs to be run with root privilege, use the following procedures to display program output on a user's X server
And root can't access user's X server without Xauthority. Do these other display managers you mention not use Xauthority method perhaps? I imagine kdm and gdm would?
github mcewanw

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#2094 Post by saintless »

sunburnt wrote:So I assume it`s a bit of code in Porteus initrd that does the alternate live-rw setup.

# Q... Will DebDog boot with Porteus initrd with Wheezy kernel.? Is there a Porteus kernel.?

I don`t know differences, but if Fred put up lots of effort, then the initrd has some advantages.
# Could make 2 partitions, 1 for DebDog and 1 for live-rw. But both in 1 has advantages.
Hi, Terry.
The reason to keep debian-boot way is to keep DebianDog 100% Debian Wheezy compatible.
The kernel is the same for porteus and debian boot.
For porteus boot we use different initrd file + small second module with porteus changes less than 1 Mb. The second module is active only if porteus-boot is choosen.
Using save folder is not the only difference between porteus and debian boot way. Porteus has many other save options that debian does not have.

# Here`s "drive-info", it`s for the USB installer.
# Please give a test try with USBs in & out and let me know...
Thank you, Terry!
I get missing disktype command message:

Code: Select all

root@debian:~# drive-info

Part Type F/R        Sizes             Drv.Label
=================================================
/opt/bin/drive-info: line 18: disktype: command not found
sda1  fix   
/opt/bin/drive-info: line 18: disktype: command not found
sdb1  rem   INTENSO

root@debian:~# 
Toni

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2095 Post by mcewanw »

Toni, SLiM and so on do use xauth but must export XAUTHORITY info whereas have to do that manually for xdm. That's what I think must happen anyway. The following link seems to suggest how that is done and also for LightDM, gdm and kdm:

http://blog.fox.geek.nz/

EDIT: I've since discovered in DebianDog that the MIT-MAGIC-COOKIE-1 key for xdm seems to be stored /var/lib/xdm/authdir/authfiles/A${DISPLAY}-* (which is similar to kdm location pointed out in the above blog). Using that it would be also possible to make a script per the method in that blog and store it in /root/.bash_profile. However, I think the methods I described above would do for now at least anyway.

I still don't understand how you were able to use su (rather than sudo) under xdm login with programs like synaptic. Didn't seem to work out of the box for me and also because needed the Xauthority exported.
Last edited by mcewanw on Mon 31 Mar 2014, 07:03, edited 1 time in total.
github mcewanw

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#2096 Post by saintless »

Hi, William.
mcewanw wrote:

Code: Select all

#!/bin/bash
if [ "`whoami`" != "root" ]; then
if [ -z "$XAUTHORITY" ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi
xterm -e sudo synaptic
exit 0
fi

synaptic
So it seems the XAUTHORITY env variable wasn't being exported to that shell for some reason......
We can use this code for synaptic till we find something better then.
9.4.12 Getting root in X If a GUI program needs to be run with root privilege, use the following procedures to display program output on a user's X server
And root can't access user's X server without Xauthority. Do these other display managers you mention not use Xauthority method perhaps? I imagine kdm and gdm would?
Maybe, but I doubt someone will ever install KDM or GDM on DebinaDog. It is better to use official debian since the small size is not possible with kdm and gdm.

The fact XDM is the first package that makes this problem for us means debian docs are not correct if not all login managers need to export xauthority.

Toni

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#2097 Post by saintless »

mcewanw wrote:Toni, SLiM and so on do use xauth but must export XAUTHORITY info whereas have to do that manually for xdm. That's what I think must happen anyway. The following link seems to suggest how that is done and also for LightDM, gdm and kdm:

http://blog.fox.geek.nz/

I still don't understand how you were able to use su (rather than sudo) under xdm login with programs like synaptic. Didn't seem to work out of the box for me and also because needed the Xauthority exported.
William,
Synaptic, Gpatrted and other programs work for user without using XDM or SLIM and with Slim installed without the changes in .bachrc and startup files. It should be mirracle since it works for me only.
I never had the changes you posted in /root/.bashrc and startup files in $HOME/

SLIM and LightDM do not need to exportapaths different way. They just use /etc/profile for this like there is no login manager installed at all.

Toni

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2098 Post by sunburnt »

Toni; Thanks, I kinda thought we did not have disktype.

What`s the installed Squash size of "parted".? I counted to over 1 MB and quit.
disktype is 40 KB in size. Needed for file system type and both sizes.

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2099 Post by mcewanw »

saintless wrote: William,
Synaptic, Gpatrted and other programs work for user without using XDM or SLIM and with Slim installed without the changes in .bachrc and startup files. It should be mirracle since it works for me only.
I never had the changes you posted in /root/.bashrc and startup files in $HOME/

SLIM and LightDM do not need to exportapaths different way. They just use /etc/profile for this like there is no login manager installed at all.

Toni
Sorry, I misunderstood a remark you made sometime earlier. I thought you were able to login via xdm to user puppy and then use su followed by calling up synaptic. That shouldn't work without Xauthority I think, but it seems you were talking about when you were not using xdm, which I understand. Note that the last link I provided above (from a blog) basically explains the difference with SLiM and LightDM and so on, compared to xdm - SLiM and LightDM seem to have an inbuilt auth mechanism which manages the provision of xauth to root on using sudo (that's what I infer anyway).

Like you suggest, we can just modify /opt/bin/synaptic-start for now and can always come back to this later if a better solution is found.
github mcewanw

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#2100 Post by saintless »

mcewanw wrote:Sorry, I misunderstood a remark you made sometime earlier. I thought you were able to login via xdm to user puppy and then use su followed by calling up synaptic. That shouldn't work without Xauthority I think.
Sorry if I didn't make it clear enough, William.
I mean exactly that:
I login via XDM to puppy user account, but I do not start synaptic with su -c. I use su-to-root:

Code: Select all

puppy@debian:~$ su-to-root -c synaptic
About to execute synaptic.
This command needs root privileges to be executed.
Using su...
Enter root password at prompt.
Password:
And Synaptic works.

Toni

Post Reply