错误/ var / tmp / kdecache由uid 1000而不是uid 0拥有

时间:2012-05-12 17:20:46

标签: c++ qt netbeans segmentation-fault kde

我正在使用Kubuntu 12.04中的NetBeans 7.1对Qt 4.8程序(http://code.google.com/p/image-feature-detector/)进行编码(尽管与Kubuntu 11.10一样),当我尝试运行编译的可执行文件时,我遇到了一个令人抓狂的错误。该程序编译和运行完美,但突然有一天我得到这个错误,经过适当的编译,我试图运行它。

如果我使用sudo运行可执行文件,这就是我得到的:

error /var/tmp/kdecache-myuser is owned by uid 1000 instead of uid 0

如果我在没有sudo的情况下运行可执行文件,我会得到:

Segmentation fault (core dumped)

如果我使用kdesudo运行可执行文件,在通过提示密码显示窗口后,没有任何反应。

如果我调试程序,调试会在访问NetBeans向我显示的程序的反汇编部分的第二行的任何源代码行之前停止:

_ZN15QAbstractButton10setCheckedEb()
Stops here->_ZN15QAbstractButton10setCheckedEb+22: mov    0x8(%rdi),%rbp
_ZN15QAbstractButton10setCheckedEb+26: mov    %esi,%r12d
_ZN15QAbstractButton10setCheckedEb+29: movzbl 0x214(%rbp),%eax
_ZN15QAbstractButton10setCheckedEb+36: test   $0x1,%al
_ZN15QAbstractButton10setCheckedEb+38: je     0x7ffff74a10d0 <_ZN15QAbstractButton10setCheckedEb+192>
_ZN15QAbstractButton10setCheckedEb+44: mov    %eax,%edx
_ZN15QAbstractButton10setCheckedEb+46: shr    %dl
_ZN15QAbstractButton10setCheckedEb+48: and    $0x1,%edx
_ZN15QAbstractButton10setCheckedEb+51: cmp    %sil,%dl
_ZN15QAbstractButton10setCheckedEb+54: je     0x7ffff74a10d0 <_ZN15QAbstractButton10setCheckedEb+192>
_ZN15QAbstractButton10setCheckedEb+60: test   %sil,%sil
_ZN15QAbstractButton10setCheckedEb+63: je     0x7ffff74a1100 <_ZN15QAbstractButton10setCheckedEb+240>
_ZN15QAbstractButton10setCheckedEb+69: mov    %rsp,%rdi
_ZN15QAbstractButton10setCheckedEb+72: mov    %rbx,(%rsp)
_ZN15QAbstractButton10setCheckedEb+76: callq  0x7ffff70bd220 <_ZN11QMetaObject8addGuardEPP7QObject@plt>
_ZN15QAbstractButton10setCheckedEb+81: movzbl 0x214(%rbp),%eax
_ZN15QAbstractButton10setCheckedEb+88: mov    %r12d,%edx
_ZN15QAbstractButton10setCheckedEb+91: and    $0x1,%edx
_ZN15QAbstractButton10setCheckedEb+94: add    %edx,%edx
_ZN15QAbstractButton10setCheckedEb+96: and    $0xfffffffd,%eax
_ZN15QAbstractButton10setCheckedEb+99: or     %edx,%eax
_ZN15QAbstractButton10setCheckedEb+101: test   $0x20,%al
_ZN15QAbstractButton10setCheckedEb+103: mov    %al,0x214(%rbp)
_ZN15QAbstractButton10setCheckedEb+109: je     0x7ffff74a10e8 <_ZN15QAbstractButton10setCheckedEb+216>
_ZN15QAbstractButton10setCheckedEb+111: mov    %rbp,%rdi
_ZN15QAbstractButton10setCheckedEb+114: callq  0x7ffff749f9f0
_ZN15QAbstractButton10setCheckedEb+119: cmpq   $0x0,(%rsp)

我试验并将/var/tmp/kdecache-myuser/的所有权更改为root(uid 0)。然后我用sudo运行我的可执行文件,我得到了一个“Segmetation fault”错误,就好像我在没有sudo的情况下运行程序一样。另外,当我更改原始/var/tmp/kdecache-looksLikeMd5Number/文件夹的权限时,会创建一个具有myuser权限的新/var/tmp/kdecache-myuser/文件夹。

我很感激任何关于如何解决这个错误的建议让我变得疯狂。

2 个答案:

答案 0 :(得分:2)

这不是一个答案,但它可能是一种简单的方法来重现您的问题,同时证明它不是您自己的代码的问题。 (问题的标题是我关注的地方:“错误:”/ var / tmp / kdecache-your_user“由uid 1000而不是uid 0”拥有。)

我认为您可以使用kdialog(Ubuntu上的kdebase-bin包的一部分)来复制此错误。我可以这样做,我希望找到一个解决方案(这就是我的问题)。

步骤:

  1. 打开终端
  2. sudo apt-get install kdebase-bin
  3. 仍在终端中,输入:

    kdialog --error "blah blah blah."

  4. 预期结果:以普通用户身份执行此kdialog时没有错误。这是我的实际结果。

  5. sudo -s(输入您的密码)
  6. 重复上述命令:

    kdialog --error "blah blah blah."

  7. 预期结果 - 它应该可以正常工作。但是,您可能会看到与您的问题相同的错误。

  8. 以下是我的实际结果:

    $ kdialog --error "blah blah blah"
    $ sudo -s
    root> kdialog --error "blah blah blah"
    Error: "/var/tmp/kdecache-computeruser" is owned by uid 1000 instead of uid 0.
    

    你甚至可能会看到更多这样的错误。我已经通过各种kdialog测试得到了这些,就像上面那样。

    Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
    Error: "/tmp/kde-your_user" is owned by uid 1000 instead of uid 0.
    Error: "/tmp/ksocket-your_user" is owned by uid 1000 instead of uid 0.
    kdeinit4: Shutting down running client.
    Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
    Error: "/tmp/ksocket-your_user" is owned by uid 1000 instead of uid 0.
    Error: "/tmp/kde-your_user" is owned by uid 1000 instead of uid 0.
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
    kbuildsycoca4 running...
    Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
    Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
    Home directory /home/your_user not ours.
    

答案 1 :(得分:0)

哦,这个错误是一个愚蠢的错误。这是在我的代码中,而不是在KDE中(是的,我们总是倾向于认为“这不能由我的错!”......)并且它与su特权无关。正如我怀疑的那样,它与指针有关。我只是尝试使用null指针的函数,恰好是setChecked()实例中的函数QAbstractdButton。是的,完全-.- ...程序正确编译,但通过运行它我在逻辑上获得了Segmentation fault

有趣的是,如果我使用sudoerror /var/tmp/kdecache is owned by uid 1000 instead of uid 0运行程序,则会出现错误。目前,如果我使用sudo运行程序,我在控制台上会出现相同的错误,但之后程序运行正常。