Reply
Thread Tools
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#1
Hi,

I'd like to announce that I ported applauncherd to Maemo Fremantle.
It's available in extras-devel, I hope it'll work smoothly.
Applauncherd port is a part of MeeCoLay project.

Download:
Code:
sudo gainroot
apt-get install applauncherd
If you'd like to support my work, you can consider donating. Thank you!

Thanks to:
  • vcproj2cmake
  • pablocrossa - both for advice in working out the compile errors

Source is available here: https://meego.gitorious.org/~marmist...o-applauncherd

Why do we need it? We have limited RAM in Fremantle, and applauncherd saves it - shares the libraries between apps.
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here

Last edited by marmistrz; 2013-09-30 at 18:32.
 

The Following 23 Users Say Thank You to marmistrz For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#2
I uploaded version 3.0.3-maemo1. This installs cleanly but there's a runtime error:
Code:
invoker: error: Failed to initiate connect on the socket.
invoker: warning: Connection with launcher process is broken
invoker: error: Start application ... as a binary executable without launcher
The first error is caused by this code:
Code:
// Inits a socket connection for the given application type
static int invoker_init(enum APP_TYPE app_type)
{
    int fd;
    struct sockaddr_un sun;

    fd = socket(PF_UNIX, SOCK_STREAM, 0);
    if (fd < 0)
    {
        error("Failed to open invoker socket.\n");
        return -1;
    }

    sun.sun_family = AF_UNIX;  //AF_FILE;

    const int maxSize = sizeof(sun.sun_path) - 1;
    if(app_type == M_APP)
    {
        strncpy(sun.sun_path, INVOKER_M_SOCK, maxSize);
    }
    else if (app_type == QT_APP)
    {
        strncpy(sun.sun_path, INVOKER_QT_SOCK, maxSize);
    }
    else if (app_type == QDECL_APP)
    {
      strncpy(sun.sun_path, INVOKER_QDECL_SOCK, maxSize);
    }
    else if (app_type == EXEC_APP)
    {
      strncpy(sun.sun_path, INVOKER_EXEC_SOCK, maxSize);
    }
    else
    {
        die(1, "Unknown type of application: %d\n", app_type);
    }

    sun.sun_path[maxSize] = '\0';

    if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) < 0)
    {
        error("Failed to initiate connect on the socket.\n");
        return -1;
    }

    return fd;
}
What may be wrong with it?
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here

Last edited by marmistrz; 2013-09-30 at 18:33.
 

The Following 2 Users Say Thank You to marmistrz For This Useful Post:
Posts: 1,808 | Thanked: 4,272 times | Joined on Feb 2011 @ Germany
#3
Originally Posted by marmistrz View Post
I uploaded version 3.0.3-maemo1. This installs cleanly but there's a runtime error:
Code:
invoker: error: Failed to initiate connect on the socket.
invoker: warning: Connection with launcher process is broken
invoker: error: Start application ... as a binary executable without launcher
The first error is caused by this code:
Code:
    if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) < 0)
What may be wrong with it?
Not sure how relevant this is, but the length you give to connect as third parameter should be the actual *used* length of the structure, i.e. not sizeof(sun) but rather sizeof(sun.sun_family) + strlen(sun.sun_path).

Also, are you sure that the listening sockets have been created?

Also, instead of just saying if(connect(...) < 0) printf("error") use the perror() function, so that you get the exact reason why connect() failed.

$ man 2 connect

Code:
The following are general socket errors only. There may be other domain-specific error codes.

EACCES
    For UNIX domain sockets, which are identified by pathname: Write permission is denied on the socket file, or search permission is denied for one of the directories in the path prefix. (See also path_resolution(7).) 
EACCES, EPERM
    The user tried to connect to a broadcast address without having the socket broadcast flag enabled or the connection request failed because of a local firewall rule. 
EADDRINUSE
    Local address is already in use. 
EAFNOSUPPORT
    The passed address didn't have the correct address family in its sa_family field. 
EAGAIN
    No more free local ports or insufficient entries in the routing cache. For AF_INET see the description of /proc/sys/net/ipv4/ip_local_port_range ip(7) for information on how to increase the number of local ports. 
EALREADY
    The socket is nonblocking and a previous connection attempt has not yet been completed. 
EBADF
    The file descriptor is not a valid index in the descriptor table. 
ECONNREFUSED
    No-one listening on the remote address. 
EFAULT
    The socket structure address is outside the user's address space. 
EINPROGRESS
    The socket is nonblocking and the connection cannot be completed immediately. It is possible to select(2) or poll(2) for completion by selecting the socket for writing. After select(2) indicates writability, use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect() completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error codes listed here, explaining the reason for the failure). 
EINTR
    The system call was interrupted by a signal that was caught; see signal(7). 
EISCONN
    The socket is already connected. 
ENETUNREACH
    Network is unreachable. 
ENOTSOCK
    The file descriptor is not associated with a socket. 
ETIMEDOUT
    Timeout while attempting connection. The server may be too busy to accept new connections. Note that for IP sockets the timeout may be very long when syncookies are enabled on the server.
That may help you debugging the problem.
 

The Following 6 Users Say Thank You to reinob For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#4
Originally Posted by reinob View Post
Not sure how relevant this is, but the length you give to connect as third parameter should be the actual *used* length of the structure, i.e. not sizeof(sun) but rather sizeof(sun.sun_family) + strlen(sun.sun_path).

Also, are you sure that the listening sockets have been created?

Also, instead of just saying if(connect(...) < 0) printf("error") use the perror() function, so that you get the exact reason why connect() failed.

$ man 2 connect

Code:
The following are general socket errors only. There may be other domain-specific error codes.

EACCES
    For UNIX domain sockets, which are identified by pathname: Write permission is denied on the socket file, or search permission is denied for one of the directories in the path prefix. (See also path_resolution(7).) 
EACCES, EPERM
    The user tried to connect to a broadcast address without having the socket broadcast flag enabled or the connection request failed because of a local firewall rule. 
EADDRINUSE
    Local address is already in use. 
EAFNOSUPPORT
    The passed address didn't have the correct address family in its sa_family field. 
EAGAIN
    No more free local ports or insufficient entries in the routing cache. For AF_INET see the description of /proc/sys/net/ipv4/ip_local_port_range ip(7) for information on how to increase the number of local ports. 
EALREADY
    The socket is nonblocking and a previous connection attempt has not yet been completed. 
EBADF
    The file descriptor is not a valid index in the descriptor table. 
ECONNREFUSED
    No-one listening on the remote address. 
EFAULT
    The socket structure address is outside the user's address space. 
EINPROGRESS
    The socket is nonblocking and the connection cannot be completed immediately. It is possible to select(2) or poll(2) for completion by selecting the socket for writing. After select(2) indicates writability, use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect() completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error codes listed here, explaining the reason for the failure). 
EINTR
    The system call was interrupted by a signal that was caught; see signal(7). 
EISCONN
    The socket is already connected. 
ENETUNREACH
    Network is unreachable. 
ENOTSOCK
    The file descriptor is not associated with a socket. 
ETIMEDOUT
    Timeout while attempting connection. The server may be too busy to accept new connections. Note that for IP sockets the timeout may be very long when syncookies are enabled on the server.
That may help you debugging the problem.
Thanks!
I'll try it out.

May optifying be the problem with connect?
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 

The Following User Says Thank You to marmistrz For This Useful Post:
Posts: 1,808 | Thanked: 4,272 times | Joined on Feb 2011 @ Germany
#5
Originally Posted by marmistrz View Post
Thanks!
I'll try it out.

May optifying be the problem with connect?
Don't see how this could be a problem, but who knows, Maemo is an absolute mess thanks to the "optification".

What values do all those INVOKER_*_SOCK variables (or #defines, whatever they are) have?

Do the sockets actually exist where they are expected to exist?

But again, your best friends are, at the moment, errno and perror(). They will tell you all you need to know.
 

The Following 2 Users Say Thank You to reinob For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#6
Originally Posted by reinob View Post
Don't see how this could be a problem, but who knows, Maemo is an absolute mess thanks to the "optification".

What values do all those INVOKER_*_SOCK variables (or #defines, whatever they are) have?

Do the sockets actually exist where they are expected to exist?

But again, your best friends are, at the moment, errno and perror(). They will tell you all you need to know.
INVOKER_*_SOCK are #defines as here https://meego.gitorious.org/~marmist...er/invokelib.h

The whole port's source is in this repo.

To be honest, I'm kinda new to all these sockets stuff. Do you know some nice article or something about it?

I'll first try removing optify.
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 

The Following User Says Thank You to marmistrz For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#7
I just noticed that files in /tmp (INVOKER_*_SOCK) - as it's -
Code:
#define INVOKER_M_SOCK     "/tmp/boostm"
#define INVOKER_QT_SOCK    "/tmp/boostq"
#define INVOKER_QDECL_SOCK "/tmp/boostd"
#define INVOKER_EXEC_SOCK  "/tmp/booste"
don't exist at all. But touching these files doesn't work. Still the error
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here

Last edited by marmistrz; 2012-07-27 at 15:18.
 

The Following User Says Thank You to marmistrz For This Useful Post:
Posts: 1,808 | Thanked: 4,272 times | Joined on Feb 2011 @ Germany
#8
Originally Posted by marmistrz View Post
I just noticed that files in /tmp (INVOKER_*_SOCK) - as it's -
Code:
#define INVOKER_M_SOCK     "/tmp/boostm"
#define INVOKER_QT_SOCK    "/tmp/boostq"
#define INVOKER_QDECL_SOCK "/tmp/boostd"
#define INVOKER_EXEC_SOCK  "/tmp/booste"
don't exist at all. But touching these files doesn't work. Still the error
I don't know what exactly you're trying to do. The nice thing about Unix and derivatives (Linux) is that (almost) everything is represented as a "file", even though some things are not files in the common sense of the word.

A unix socket is an example of that. It looks like a file you can open, read and write to, but it is not a file. So touch'ing it makes no sense. touch will create a (real) file of zero size.

Presumably you'd need to run the program that actually creates those sockets and listens (binds) on them.

I don't know what applauncher does, nor do I care. I suspect it's one of those over-complicated "abstraction layers" that supposedly bring nice effects (splash screen? single instance? what has happend to Linux?!) where actually they only make everything more complicated to understand as well as contributing to the dependency hell we're living in.

If you really want to port applauncher to Fremantle I'd recommend that you debug your program using the perror() function. Really, it's the best thing you can do at the moment to diagnose the situation.

If Harmattan programs actually *require* this contraption, I would recommend you make a dummy/fake applauncherd so that programs can be run like normal programs. Then the user would be able to install the real "thing" or the fake one (hint: "provides", "conflicts", since we're playing the debian game).

Good luck anyway!

Last edited by reinob; 2012-07-30 at 08:07. Reason: removed [code] as it doesn't work inline
 

The Following 4 Users Say Thank You to reinob For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#9
Originally Posted by reinob View Post
I don't know what exactly you're trying to do. The nice thing about Unix and derivatives (Linux) is that (almost) everything is represented as a "file", even though some things are not files in the common sense of the word.

A unix socket is an example of that. It looks like a file you can open, read and write to, but it is not a file. So touch'ing it makes no sense. touch will create a (real) file of zero size.

Presumably you'd need to run the program that actually creates those sockets and listens (binds) on them.

I don't know what applauncher does, nor do I care. I suspect it's one of those over-complicated "abstraction layers" that supposedly bring nice effects (splash screen? single instance? what has happend to Linux?!) where actually they only make everything more complicated to understand as well as contributing to the dependency hell we're living in.

If you really want to port applauncher to Fremantle I'd recommend that you debug your program using the perror() function. Really, it's the best thing you can do at the moment to diagnose the situation.

If Harmattan programs actually *require* this contraption, I would recommend you make a dummy/fake applauncherd so that programs can be run like normal programs. Then the user would be able to install the real "thing" or the fake one (hint: "provides", "conflicts", since we're playing the debian game).

Good luck anyway!
I guess I know what's the problem. I read somewhere that applauncherd is run as a privileged process. So I guess, that applauncherd would like to create sockets but can't.

Sudo'ing single-instance causes no probems. The app does load faster. I'll look at perroring for invoker, but as for now, is there any way to add more privileges to applauncherd?
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 

The Following 2 Users Say Thank You to marmistrz For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#10
OK, I've got some progress!

I've got a new built, totally without platform security. segfaults but later. The log is:

Code:
invoker: Invoking execution: '/opt/SzybkiDemot/bin/SzybkiDemot'
invoker: error: Can't send signal 11 to application [10043]: No such process
and from `sudo run-standalone.sh applauncherd --debug`

Code:
Running non-meego graphics system enabled  MeeGo touch, forcing native graphicssystem

Object::disconnect: Unexpected null parameter
Daemon: select done.
Daemon: FD_ISSET(m_boosterLauncherSocket[0])
Daemon: booster type: d

Daemon: invoker's pid: 10046

Daemon: respawn delay: 3 

Daemon: socket file descriptor: 12

Daemon: select done.
Daemon: FD_ISSET(m_sigPipeFd[0])
Daemon: SIGCHLD received.
Daemon: Terminated process had a mapping to an invoker pid
Boosted process (pid=10043) was terminated due to signal 11

Daemon: Booster (pid=10043) was terminated due to signal 11

Daemon: Killing invoker process (pid=10046) by signal 11..

Daemon: Killing pid 10046 with 11
Daemon: Running a new Booster of type 'd'
Running non-meego graphics system enabled  MeeGo touch, forcing native graphicssystem
The graphics-system stuff is due to linking to meegotouch (mbooster). Any ideas why is it like that? ps shows the relevant booster with the right process number.

download:

http://marmistrz.net63.net/public/applauncherd/

/edit: You can install the test packages and try out /usr/share/applauncherd-tests/* Don't mind the broken deps.
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here

Last edited by marmistrz; 2013-09-29 at 18:41.
 

The Following 5 Users Say Thank You to marmistrz For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 18:17.