avidemux3_jobs_qt5 not running as user but does as root

Started by quantumchaos451, January 21, 2018, 04:56:27 AM

Previous topic - Next topic


Issue: avidemux3_jobs_qt5 doesn't start if I run it as a user but does as root.

History: I recently had to rebuild my machine and I built avidemux from the 2.7 source. The avidemux3_qt5 program itself works fine but avidemux3_jobs_qt5 fails with the error given below. Thinking it was something to do with my build I tried two other versions of avidemux. One was from the unofficial Ubuntu ppaand the other was building avidemux from the latest git master. Both gave the same issue - avidemux3_qt5 would work fine but avidemux3_jobs_qt5 wouldn't run unless run as root. So I tried avidemux from unofficial Ubuntu ppa on another machine which has not been recently rebuilt and had exactly the same issue. So that seem to indicate that the issue did not lie with my rebuild. I have never had this issue before running avidemux3_jobs_qt5 which I use quite extensively. In the past I have used both the binaries from unofficial Ubuntu ppa and building my own from the avidemux 2.7 source code successfully.

I'm at a little bit of loss as to why it is failing so if someone could please point me in the right direction I would much appreciate it.

Running as user:
~$ avidemux3_jobs_qt5
  Avidemux v2.7.0 (180120_c740522a65c)

Compiler: GCC 7.2.0
Build Target: Linux (x86-64)

Large file available: 1 offset
Directory /home/scott/.avidemux6/ exists.Good.
Using /home/scott/.avidemux6/ as base directory for prefs, jobs, etc.
[jobInit] 04:37:31-332  Initializing database (/home/scott/.avidemux6/jobs.sql)
[ADM_jobCheckVersion] 04:37:31-332  Db version 3, our version 3
[ADM_jobCheckVersion] 04:37:31-332  Same version, continuing..
[jobInit] 04:37:31-332  Successfully connected to jobs database..
[createBindAndAccept] 04:37:31-593  Binding on
[createBindAndAccept] 04:37:31-594  bind() failed 
[close] 04:37:31-594  [ADMSocket]Error when socket shutdown  -1 (socket 10)
[popup] 04:37:31-594  Cannot bind socket
Cleaning up
[jobShutDown] 04:37:31-597  Shutting down jobs database
[onexit] 04:37:31-597 

Running as root:
~# avidemux3_jobs_qt5
  Avidemux v2.7.0 (180120_c740522a65c)

Compiler: GCC 7.2.0
Build Target: Linux (x86-64)

Large file available: 1 offset
Directory /root/.avidemux6/ exists.Good.
Using /root/.avidemux6/ as base directory for prefs, jobs, etc.
[jobInit] 04:37:38-595  Initializing database (/root/.avidemux6/jobs.sql)
[ADM_jobCheckVersion] 04:37:38-629  Db version 3, our version 3
[ADM_jobCheckVersion] 04:37:38-629  Same version, continuing..
[jobInit] 04:37:38-629  Successfully connected to jobs database..
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
[createBindAndAccept] 04:37:39-095  Binding on
[createBindAndAccept] 04:37:39-095  Socket bound to port 13921
[jobWindow] 04:37:39-095  Socket bound to 13921
[refreshList] 04:37:39-096  Found 0 jobs
[uninstallSigHandler] 04:37:41-741  Removing signal handler
Normal exit
Cleaning up
[jobShutDown] 04:37:41-742  Shutting down jobs database
[onexit] 04:37:41-742 


Jan Gruuthuse

Open terminal as user $:
  Avidemux v2.7.0 (180120_b2b79ea9f57)
Code      : Mean, JSC, Gruntster
GFX       : Nestor Di , nestordi@augcyl.org
Design    : Jakub Misak
FreeBSD   : Anish Mistry, amistry@am-productions.biz
Audio     : Mihail Zenkov
MacOsX    : Kuisathaverat
Win32     : Gruntster

Compiler: GCC 5.4.0 20160609
Build Target: Linux (x86-64)

Large file available: 1 offset
Directory /home/jan/.avidemux6/ exists.Good.
Using /home/jan/.avidemux6/ as base directory for prefs, jobs, etc.
[jobInit] 12:17:08-705  Initializing database (/home/jan/.avidemux6/jobs.sql)
[ADM_jobCheckVersion] 12:17:08-719  Db version 3, our version 3
[ADM_jobCheckVersion] 12:17:08-719  Same version, continuing..
[jobInit] 12:17:08-719  Successfully connected to jobs database..
[createBindAndAccept] 12:17:08-968  Binding on
[createBindAndAccept] 12:17:08-968  Socket bound to port 23024
[jobWindow] 12:17:08-968  Socket bound to 23024
[refreshList] 12:17:08-968  Found 0 jobs

perhaps is related to this?
Quote from: Jan Gruuthuse on January 07, 2018, 08:18:29 AM
with following instructions:
remove and delete installed avidemux
sudo apt-get purge "avidemux*"

Odd that something goes wrong for user with bind? Kind of permission?
You did install with
cd ~/avidemux2/debs && sudo dpkg -i *.deb


OK. This just got weirder.

As I was at work when I received your reply and logged into my home machine via ssh, did the apt purge avidemux* and then rebuilt avidemux from git, and using X-forwarding ran it and it worked (I have Centos at work). To make sure I created a remote desktop session to my home PC and tried it. It gave me the same error...

When I got home I started playing with the widget styles - avidemux3_jobs_qt5 will work if I set the widget style to MS Windows 9x or kvantum. It won't work for Breeze, Fusion and Oxygen widget styles...

It makes no sense to me but it is at least consistent. I did it numerous times to make sure it was actually the issue.


Jan Gruuthuse

This is beyond my user experience.
Perhaps developers have an idea what could be going on?


OK. Tracked down the what even if not the why.

Using strace -f -e trace=network I found the following. If the widget style is MS Windows 9x I end up with this:

[createBindAndAccept] 09:04:53-011  Binding on                                 
[pid  3184] bind(11, {sa_family=AF_INET, sin_port=htons(6768), sin_addr=inet_addr("")}, 16) = 0

Port 6768 is greater than 1024 so allowed.

But with the Breeze style for example I end up with this:

[createBindAndAccept] 09:01:01-999  Binding on
[pid 31141] bind(11, {sa_family=AF_INET, sin_port=htons(103), sin_addr=inet_addr("")}, 16) = -1 EACCES (Permission denied)

Port 103 is < 1024 and therefore is forbidden.

What I did find is that if you do it enough times eventually both will fail/work. What the widget style appears to be having is an effect on the is the initial port number chosen - the frequency with which it happens makes me think it may be valid but I'm open to correction on that. I have no idea how the random port number passed in (port is never initialised as far as I can see - the default appears to be whatever is in that memory space) is converted to a valid port number.

I've fixed it by applying the patch below but it will need a proper fix at some stage.

diff --git a/avidemux_core/ADM_coreSocket/src/ADM_coreSocket.cpp b/avidemux_core/ADM_coreSocket/src/ADM_coreSocket.cpp
index 8add543ed..06c55a6bd 100644
--- a/avidemux_core/ADM_coreSocket/src/ADM_coreSocket.cpp
+++ b/avidemux_core/ADM_coreSocket/src/ADM_coreSocket.cpp
@@ -89,7 +89,7 @@ bool ADM_socket::connectTo(uint32_t port)
     service.sin_family = SNET;
     service.sin_addr.s_addr = inet_addr(BIND_ADR);
     service.sin_port = htons(port);

     if(connect(mySocket,(struct sockaddr *)&service,sizeof(service)))
@@ -184,30 +184,35 @@ if (setsockopt(mySocket, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0)
     ADM_error("Oops : setsockopt(SO_REUSEADDR) failed\n");

+  if ((unsigned int)*port <= 1024 || (unsigned int)*port > 65535)
+  {
+      *port = 15234;
+  }
   ADM_info("Binding on %s:%d\n",BIND_ADR,*port);
   sockaddr_in service;
   service.sin_family = AF_INET;
   service.sin_addr.s_addr = inet_addr(BIND_ADR);
   service.sin_port = htons(*port); // bind to any port

15234 was just a random port I chose.



I didn't notice https://github.com/mean00/avidemux2/pull/152 and the last reply in this topic and fixed the uninitialized use of localPort independently.