Friday, January 28, 2011

qemu Ctrl-Alt

While have to work with qemu, I noticed nasty thing - when one often
switches backward-and-forward between guest and host, qemu (or guest?)
goes insane about Left Ctrl key and assumes it's pressed constantly.
Boom, believe me or not, guest becomes totally unusable.

By default qemu use LCtrl-LAlt to grab/release input. I changed it
to RALT - it's not that I use this key much anyway, I'm not even sure I
ever did.

"If you can't live with it - patch it!"

---

diff --git a/ui/sdl.c b/ui/sdl.c
index f599d42..606cc36 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -49,7 +49,7 @@ static int gui_noframe;
 static int gui_key_modifier_pressed;
 static int gui_keysym;
 static int gui_fullscreen_initial_grab;
-static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
+static int gui_grab_code = KMOD_RALT; //KMOD_LALT | KMOD_LCTRL;
 static uint8_t modifiers_state[256];
 static int width, height;
 static SDL_Cursor *sdl_cursor_normal;
@@ -425,7 +425,7 @@ static void sdl_update_caption(void)
         else if (ctrl_grab)
             status = " - Press Right-Ctrl to exit mouse grab";
         else
-            status = " - Press Ctrl-Alt to exit mouse grab";
+            status = " - Press RALT to exit mouse grab"; //" - Press Ctrl-Alt to exit mouse grab";
     }

     if (qemu_name) {

Thursday, January 27, 2011

Fox News "The Internet Is Nearly Out of IP Addresses"

Sometimes you just can't walk around.

The Internet Is Nearly Out of IP Addresses


It's the end of the web as we know it. 
Every Internet-connected computer, smartphone, car, gadget and gizmo is assigned a four-digit IP address that lets it communicate with the net, thanks to a system known as IPv4 (Internet Protocol version 4). And the flood of new gadgets means we're running out of those addresses.
[..]
Web developers have tried to compensate for this problem by creating IPv6 -- a system that recognizes six-digit IP addresses rather than four-digit ones.
[..]
But IPv6 isn't backwards-compatible with IPv4, meaning that it's not able to read most content that operates on an IPv4 system. At best, the user experience will be clunky and slow. At worst, instead of a webpage, all users will be able to view is a blank page.

via Fox News

thanks avva

Make it fun again!

Wednesday, January 26, 2011

gcc-4.6 status report

Jakub Jelinek has published gcc-4.6 status report for 2011-01-26

 

Quality Data
============


Priority # Change from Last Report
-------- --- -----------------------
P1 10 - 21
P2 101 - 8
P3 21 - 7
-------- --- -----------------------
Total 132 - 36


Promising 4.6 features list

Wednesday, January 19, 2011

libcap 2.20

libcap 2.20 just has been released (release notes) by Andrew G Morgan.

  • Latest kernel capabilites supported: now includes CAP_SYSLOG
  • $(CFLAGS) Makefile fixes from Torsten Werner
  • Default to installing setcap with an inheritable capability.
    • You can disable this feature with: make RAISE_SETFCAP=no install

Thursday, January 13, 2011

CAP_SYSLOG

Patches

commit 38ef4c2e437d11b5922723504b62824e96761459
Author: Serge E. Hallyn
Date:   Wed Dec 8 15:19:01 2010 +0000

    syslog: check cap_syslog when dmesg_restrict
   
    Eric Paris pointed out that it doesn't make sense to require
    both CAP_SYS_ADMIN and CAP_SYSLOG for certain syslog actions.
    So require CAP_SYSLOG, not CAP_SYS_ADMIN, when dmesg_restrict
    is set.
   
    (I'm also consolidating the now common error path)
   

commit ce6ada35bdf710d16582cc4869c26722547e6f11
Author: Serge E. Hallyn
Date:   Thu Nov 25 17:11:32 2010 +0000

    security: Define CAP_SYSLOG
   
    Privileged syslog operations currently require CAP_SYS_ADMIN.  Split
    this off into a new CAP_SYSLOG privilege which we can sanely take away
    from a container through the capability bounding set.
   
    With this patch, an lxc container can be prevented from messing with
    the host's syslog (i.e. dmesg -c).
   
    Changelog: mar 12 2010: add selinux capability2:cap_syslog perm
    Changelog: nov 22 2010:
        . port to new kernel
        . add a WARN_ONCE if userspace isn't using CAP_SYSLOG
   

introduced new CAP_SYSLOG capability and changed required capability
for syslog operations from CAP_SYS_ADMIN to CAP_SYSLOG:

int do_syslog(int type, char __user *buf, int len, bool from_file)
{
    [..]
    if (type == SYSLOG_ACTION_OPEN || !from_file) {
        if (dmesg_restrict && !capable(CAP_SYSLOG))
            goto warn; /* switch to return -EPERM after 2.6.39 */
        if ((type != SYSLOG_ACTION_READ_ALL &&
             type != SYSLOG_ACTION_SIZE_BUFFER) &&
            !capable(CAP_SYSLOG))
            goto warn; /* switch to return -EPERM after 2.6.39 */
    }

[...]

It also broke my syslog-ng
[   22.387886] ------------[ cut here ]------------
[   22.387899] WARNING: at kernel/printk.c:429 do_syslog+0x427/0x452()
[   22.387903] Hardware name: Aspire 5741G   
[   22.387905] Attempt to access syslog with CAP_SYS_ADMIN but no CAP_SYSLOG (deprecated and denied).
[..] Call Trace [..]



The problem, is that setcap still don't know about CAP_SYSLOG

# setcap  'cap_sys_admin=+pe' syslog-ng
# setcap  'cap_syslog=+pe' syslog-ng
fatal error: Invalid argument
usage: setcap [-q] [-v] (-r|-|) [ ... (-r|-|) ]

 Note must be a regular (non-symlink) file.

Tuesday, January 4, 2011

Throwing non-throwing operator new

When we write
foo *p = new(std::nothrow) foo;

we still have probability of uncatched bad_alloc.
The following code may look confusing (and it does),
though it works perfect

try {
        p = new(std::nothrow) foo;
} catch (std::bad_alloc&) {
        exit(0); //nevermind
}


The `problem' could be in foo::foo, e.g.
foo::foo() {
        member = new int[0x7fffffff];
}


since nothrow_t works only for outer allocation and
leaves room for bad_alloc in .ctor.

operator new (std::size_t sz, const std::nothrow_t&) throw()
{
  void *p;

  /* malloc (0) is unpredictable; avoid it.  */
  if (sz == 0)
    sz = 1;
  p = (void *) malloc (sz);
  while (p == 0)
    {
      new_handler handler = __new_handler;
      if (! handler)
        return 0;
      __try
        {
          handler ();
        }
      __catch(const bad_alloc&)
        {
          return 0;
        }

      p = (void *) malloc (sz);
    }

  return p;
}