Linux kernel: Hide Processes From Other Users

Just learned clever trick – use hidepid mount-option to hide processes from other users. Useful when managing shared servers. And it’s available since 2011 (patch released 2011, appeared in kernel 3.3 at 2012)!

Try it out on live system

$ mount -o remount,rw,hidepid=2 /proc

Add hidepid= and gid= mount options. hidepid=0 means classic mode – everybody may access all /proc// directories (default). hidepid=1 means users may not access any /proc// directories but their own. hidepid=2 means hidepid=1 plus all /proc// will be fully invisible to other users. gid= defines a group authorized to learn processes information otherwise prohibited by hidepid=

If ready to make change permanent, add line to /etc/fstab:

proc    /proc    proc    defaults,hidepid=2     0     0
Posted in Uncategorized | Leave a comment

KDE: when activities are messed up

Got into strange situation yesterday.

I was poking some exotic key-compinations like alt+everything and ctrl+everything and <super>+everything, as suddenly all windows wanished. Whatta..!?

It turned out, that it was <super>+S that stopped my current activity. But as I’m not acivity-user nor fan of it (virtual desktops are good and enough for me) I wasn’t sure what I see or what I can do. Opening Konsole I saw, that my processes were still running, so it wasn’t some mysterious X- or gpu-crash.

As I suspected, some activity trick it might be. I removed one as I had two of them. Nothing. Then I changed task-manager, that it would show windows from other activities. YESS… there they were, but ofcourse – not usable.

Hardcore
You think, that you could find some mythical options like:
* transfrer all windows from other activities to current one? No!
* Move all windows to… ? No!
* Eerm.. fix activity state? No 🙁
* Would relogin or restart fix it? No :((

So I removed for first thing activity* files from .kde4/share/config. No help. But then, as programmer I thought, that there should be some relation between objects “activity” and “window”.. and seemed that .kde4/share/config/kwin… file contained it. Deleted it and after relogin – GREAT SUCCESS! All session-saved windows were back to default activity.

Day is saved again.

Posted in Uncategorized | Leave a comment

Updating synergy, “invalid shell library”

Just got problem, when tried to update synergy on my 64bit Win7 box. Seemed that installation went well, but when synergy started one line showed:

ERROR: invalid shell library, use a newer synwinxt.dll

Tried reinstall, and clicked on “Show details” on installer window. There was an interesting line, that told “synwinxt.dll already existed” (or something similar). So, I did uninstall, and whoa – there still was existing c:\Program Files\Synergy\synwinxt.dll” file. Tried to delete, but no success – window$ said, this file was used by explorer.

Solution:

* Uninstall synergy
* restart windows
* delete c:\Program Files\Synergy
* install synergy

Posted in Uncategorized | Leave a comment

PHP One Line Gallery

Just created new sub-page – Php One Line Gallery. It will be home of my short version of gallery code written in PHP.

Posted in Uncategorized | Leave a comment

Gentoo: conflict between usbutils and hwids

[blocks B      ] <sys-apps/usbutils-005-r1 ("<sys-apps/usbutils-005-r1" is blocking sys-apps/hwids-20120922)

 * Error: The above package list contains packages which cannot be
 * installed at the same time on the same system.

  (sys-apps/usbutils-004::gentoo, installed) pulled in by
    >=sys-apps/usbutils-0.82 required by (sys-fs/udev-171-r6::gentoo, installed)
    sys-apps/usbutils required by (kde-base/kinfocenter-4.9.2::gentoo, ebuild scheduled for merge)

  (sys-apps/hwids-20120922::gentoo, ebuild scheduled for merge) pulled in by
    sys-apps/hwids required by (sys-apps/pciutils-3.1.10::gentoo, ebuild scheduled for merge)
    sys-apps/hwids required by (sys-fs/udev-171-r6::gentoo, installed)


For more information about Blocked Packages, please refer to the following
section of the Gentoo Linux x86 Handbook (architecture is irrelevant):

Solution
* remove usbutils

emerge -Ca sys-apps/usbutils

* as at this point emerging usbutils is still impossible (now conflict with pciutils) remerge it

emerge -a sys-apps/pciutils

* and now emerge usbutils

emerge -a sys-apps/usbutils
Posted in Uncategorized | 2 Comments

Linux Mint 13 and sunoracle java

Although I’m on the way to move away from Linux Mint (epic shortage of functionality – it is a modern OS but you CAN’t dist-upgrade, in the same time – all other OS’es CAN do it) it still run’s on few of my boxes and it (MATE version) runs nicely on older hardware. So.. there is not anymore sun’s jdk and oracle’s jdk not available in (default) package management. Yeah, there is few alternatives, but they are not… wokring well. For example this won’t play with no other jdk but sunoracle’s.

Here’s three commands to fix it:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
Posted in Uncategorized | Leave a comment

Kate and replace with regular expressions

Just got good experience with KDE’s Kate editor and must share it.

You have piece of code, which looks like this

if(get_var('submit')){
    // still empty..
}else{
    $var1=null;
    $var2=null;
    ...
    $var100=null;
}

and now you need to put those initializations of var’s to the first block also, getting variables from GET or POST supervariables. What to do? Doing hunderd times of “delete null, paste get_var(”), copy-paste ‘name of variable'” and the day is going to be sooooo long …

Now, in Kate you can do it by one click. Copy all lines “$var..=null;” to first block, select those lines and “ctrl+r” (replace) and put values:

Find: \$(.*)=null;
Replace: \$\1=get_var('\1');
Mode: Regular expression
[V] Selection Only (just incase)

and press “Replace All”. And it’s done:

if(get_var('submit')){
    $var1=get_var('var1');
    $var2=get_var('var2');
    ...
    $var100=get_var('var100');
}else{
    $var1=null;
    $var2=null;
    ...
    $var100=null;
}

and explained:
In Find expression you see (.*) – content of parentheses are treated as parameter “one” and referenced later as \1. That what you see in Replace expression \$\1 – will get replaced as “$var1” and get_var(‘\1’) gets get_var(‘var1’)

Posted in Uncategorized | 2 Comments

Force Moodle to put Dataroot under website root

Had to help install Moodle today. Pretty ugly experience comparing for example to wordpress installation.

Main problem was that Moodle forces you to put dataroot directory outside of webroot directory. Not going to argue is it magic cure against all evil and bad or not, but two things are sure:

a) User needs options, and decision should be he’s (just warning should be ok, and default restricting .htaccess file)
b) If you are using some hostingserver or have some-kind setup which doesn’t allow your php script to access files outside from wwwroot, then you are in deep problems.

But, there is atleast one good solution 😀 And that’s directly related to power of open source – if you don’t like something, CHANGE IT!

Solution:

* Open in your favorite editor file MOODLE_INSTALL_DIR/lib/adminlib.php
* find function is_dataroot_insecure
* add return false; directly after function header, so it looks like this

function is_dataroot_insecure($fetchtest=false) {
    return false;
    global $CFG;
...

it allows you to put datadir wherever you want and test or use it on your own risk.

Other problems were somehow related to installer, and seems that it thinks, that you have all power on database you ever can (in other words – you have root-like permissions). So lot of messages “table already exists” and so on. And later.. some magical message “DDL sql execution error” – whatta hek is that?

As it happes on import, it is related to creation of temporary tables. WHY can’t it be cheked in installation time or given some HUMAN-readable message. Fix it:

GRANT CREATE TEMPORARY TABLES ON `database`.* TO 'username';
Posted in Uncategorized | Leave a comment

Linux Mint installation dvd asks username and password?

Downloaded and tried to install Linux Mint 12 today.

After burning DVD and booting up it in my laptop I got username and password prompt in graphical interface. At first I tried mint/[no password], mint/mint, install/[no password] and so on and on. Even tought that maybe it asks user and password of existing installation on disk. After that I tried search installation manual but no reference to username and password. So.. whatta hek?

but after lots of googling I found this and got next idea to check md5sum of iso and burned disk. but..

How to checksum already burned DVD?
Okay, before I got to DVD I already discovered that iso on disk is not good anymore, md5sum was different from that was said on Mint’s page. But how did that happen, as I already controlled iso and it WAS ok!? Problem was that during download computer crashed, and later I started new download before I discovered that old download was resumed by firefox. Anyway.. smth was broken. Third DVD was already success:)

but back to question. You can check your iso file md5 by running command (note, this is correct iso)

$ md5sum linuxmint-12-gnome-dvd-64bit.iso
548f0ac303fea840ef138e5669880a74  linuxmint-12-gnome-dvd-64bit.iso

to check already burned DVD or CD, you must know the size, as for one way I figured out. With “ls -l” you get 1066518528, and now it must be divided with 2048 as block size: 1066518528/2048=520761

# calculate md5sum on invalid file:
$ md5sum linuxmint-12-gnome-dvd-64bit.iso 
86788cd20f20f1f370c833c650c16838  linuxmint-12-gnome-dvd-64bit.iso

# check md5sum of DVD
$ dd if=/dev/cdrom4 bs=2048 count=520761 | md5sum 
520761+0 records in
520761+0 records out
1066518528 bytes (1.1 GB) copied, 125.79 s, 8.5 MB/s
86788cd20f20f1f370c833c650c16838  -

why is this impotrant, or why you can’t just sum whole device? Some additional burining info is added to DVD…

Posted in Uncategorized | Leave a comment

rdesktop: how to switch off from fullscreen?

Looked for that solution alrady long time, but no acively – just thought about it – if using remote connection in Windows, there is additional bar on top of screen, but whatabout rdesktop?

And as I found out, there is nice solution. Just press ctrl + alt + enter – it switces off or on fullscreen mode.

Posted in Uncategorized | Leave a comment