beep exits without producing the sound. strace beep execve("/usr/bin/beep", ["beep"], [/* 93 vars */]) = 0 uname({sys="Linux", node="blight", ...}) = 0 brk(0) = 0x804b000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=247770, ...}) = 0 mmap2(NULL, 247770, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f06000 close(3) = 0 open("/lib/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20P\1\000"..., 512) = 512 fstat64(3, {st_mode=S_IFREG|0755, st_size=1186936, ...}) = 0 mmap2(NULL, 1158364, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7deb000 mmap2(0xb7f00000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x114) = 0xb7f00000 mmap2(0xb7f04000, 7388, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f04000 close(3) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7dea000 mprotect(0xb7f00000, 4096, PROT_READ) = 0 mprotect(0xb7f58000, 4096, PROT_READ) = 0 set_thread_area({entry_number:-1 -> 6, base_addr:0xb7deaa90, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 munmap(0xb7f06000, 247770) = 0 open("/dev/urandom", O_RDONLY) = 3 read(3, "\337%\264\277", 4) = 4 close(3) = 0 brk(0) = 0x804b000 brk(0x806c000) = 0x806c000 rt_sigaction(SIGINT, {0x8048780, [INT], SA_RESTART}, {SIG_DFL}, 8) = 0 open("/dev/console", O_WRONLY) = -1 EACCES (Permission denied) fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 1), ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f42000 write(1, "\7", 1) = 1 nanosleep({0, 200000000}, NULL) = 0 close(-1) = -1 EBADF (Bad file descriptor) munmap(0xb7f42000, 4096) = 0 exit_group(0) = ? i saw a permission denied on console. so i gave the right permissions: execve("/usr/bin/beep", ["beep"], [/* 93 vars */]) = 0 uname({sys="Linux", node="blight", ...}) = 0 brk(0) = 0x804b000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=247770, ...}) = 0 mmap2(NULL, 247770, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f37000 close(3) = 0 open("/lib/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20P\1\000"..., 512) = 512 fstat64(3, {st_mode=S_IFREG|0755, st_size=1186936, ...}) = 0 mmap2(NULL, 1158364, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e1c000 mmap2(0xb7f31000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x114) = 0xb7f31000 mmap2(0xb7f35000, 7388, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f35000 close(3) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e1b000 mprotect(0xb7f31000, 4096, PROT_READ) = 0 mprotect(0xb7f89000, 4096, PROT_READ) = 0 set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e1ba90, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 munmap(0xb7f37000, 247770) = 0 open("/dev/urandom", O_RDONLY) = 3 read(3, "CZ\262\205", 4) = 4 close(3) = 0 brk(0) = 0x804b000 brk(0x806c000) = 0x806c000 rt_sigaction(SIGINT, {0x8048780, [INT], SA_RESTART}, {SIG_DFL}, 8) = 0 open("/dev/console", O_WRONLY) = 3 ioctl(3, KIOCSOUND, 0xa97) = -1 EPERM (Operation not permitted) nanosleep({0, 200000000}, NULL) = 0 ioctl(3, KIOCSOUND, 0) = -1 EPERM (Operation not permitted) close(3) = 0 exit_group(0) now iotcl fails. using as root works. what's wrong? i've been using beep for ages as simple user, it got fucked after some udev updates. however now: ls /dev/console -l crw-rw---- 1 root wheel 5, 1 5 gen 14:28 /dev/console and i'm in the wheel group.
I have no idea to which ebuild does /usr/bin/beep belong, also emerge --info and udev version missing. Reopen with the needed information.
emerge info Portage 2.1_pre3-r1 (default-linux/x86/2005.1, gcc-3.4.5, glibc-2.3.6-r0, 2.6.15 i686) ================================================================= System uname: 2.6.15 i686 Pentium III (Katmai) Gentoo Base System version 1.12.0_pre13 distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] ccache version 2.4 [disabled] dev-lang/python: 2.4.2 sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.59-r7 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1 sys-devel/binutils: 2.16.1-r1 sys-devel/libtool: 1.5.22 virtual/os-headers: 2.6.11-r3 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CBUILD="i686-pc-linux-gnu" CFLAGS="-O3 -mtune=pentium3 -march=pentium3 -pipe -fomit-frame-pointer -mmmx -msse" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /etc/mail/dspam /opt/openjms/config /usr/kde/2/share/config /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /var/bind /var/qmail/control /var/run/dspam" CONFIG_PROTECT_MASK="/etc/gconf /etc/splash /etc/terminfo /etc/texmf/web2c /etc/env.d" CXXFLAGS="-O3 -mtune=pentium3 -march=pentium3 -pipe -fomit-frame-pointer -mmmx -msse" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig distlocks fixpackages sandbox sfperms strict" GENTOO_MIRRORS="http://gentoo.ngi.it http://www.die.unipd.it/pub/Linux/distributions/gentoo-sources/" LANG="it_IT@euro" LC_ALL="it_IT@euro" LINGUAS="it" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/mnt/Dati/Gentoo/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage" USE="x86 X X509 Xaw3d a52 aac aalib accessibility acl acpi activefilter adns alsa apache2 apm arts asf audiofile avi bash-completion berkdb bidi bitmap-fonts bonobo bootsplash browserplugin bzip2 cairo caps cdb cdda cddb cdio cdparanoia cdr cgi chroot clamav cli client codecs crypt css cups curl dba dbus dga dhcp directfb djbfft dri edl eds emboss encode ethereal exif expat extraengine faac faad fam fbcon ffmpeg fftw flac flash foomaticdb foreign-package fortran freetds gcj gd gdbm geometry ggi gif gimp gimpprint glut glx gmp gnokii gnome gphoto2 gpm graphviz gs gstreamer gtk gtk2 gtkhtml guile h264 hal iconv idea idn imagemagick imap imlib innodb irda irmc jack java javascript jikes jit joystick jpeg jpeg2k junit justify kde kdeenablefinal kerberos kqemu lame lcd lcms ldap libcaca libclamav libg++ libgda libusb libwww lirc live lm_sensors lua lzo mad mailwrapper matroska md5sum mdb mhash mikmod mime ming mmx mmx2 mmxext mng mono motif mozcalendar mozdevelop mozilla mozsvg mozxmlterm mp3 mp4live mpeg mpeg2 mpeg4 mplayer mysql mysqli mythtv nagios-dns nagios-ntp nagios-ping nagios-ssh ncurses neXt network ngui nls nntp no_wxgtk1 nobsh nopie nossp noxalan nptl nptlonly nsplugin oav odbc ogg oggvorbis openal opengl operanom2 oss pam pcre pda pdf pdflib pdo pear perl php png pnp postgres ppds pthreads python qemu-fast qhull qt quicktime quotas readline real rrdtool rtc ruby samba scanner sdl server session sftplogging sguil slang slp snortsam soap sockets socks5 softmmu softquota spamassassin speex spell sqlite3 sse ssl subject-rewrite svg svga tcltk tcpd tetex tga theora tiff tokenizer truetype truetype-fonts trusted type1-fonts udev usb userlocales vidix vorbis win32codecs wmf wsconvert wxwindows x264 xanim xchatdccserver xchattext xine xinerama xml xml2 xmlrpc xmms xosd xpm xprint xsl xv xvid xvm xvmc zlib elibc_glibc kernel_linux linguas_it userland_GNU" Unset: ASFLAGS, CTARGET, LDFLAGS, MAKEOPTS udev 0.79 and linux 2.6.15 beep belongs to app-misc/beep-1.2.2-r1
Solar: I'm afraid forcing it to not be suid was the cause of this problem. In essence, beep will work at the moment if you are root or the owner of the current TTY (this is a limit imposed by ioctl(), so there isn't really anything we can do about it). The only way around it is to make beep suid. From http://www.johnath.com/beep/README: "Decide for yourself, of course, but it looks safe to me - there's only one buffer and fgets doesn't let it overflow, there's only one file opening, and while there is a potential race condition there, it's with /dev/console. If someone can exploit this race by replacing /dev/console, you've got bigger problems. :)" Solar, I'm leaving this to you to decide. I'm okay with recommending users suid if they are concerned about the security risks (although I can't quite fathom any) in an einfo. However, I'd prefer just to add the suid back to the ebuild.
(In reply to comment #3) > Solar: I'm afraid forcing it to not be suid was the cause of this problem. > > In essence, beep will work at the moment if you are root or the owner of the > current TTY (this is a limit imposed by ioctl(), so there isn't really anything > we can do about it). The only way around it is to make beep suid. From > http://www.johnath.com/beep/README: That is what the patch I provided fixed. perhaps you did not add that? http://dev.gentoo.org/~solar/patch_overlay/app-misc/beep/beep-1.2.2-nosuid.patch If the ioctl can't happen a classic \a beep is printed.
sorry, but it worked some time ago...had i a suid so?
(In reply to comment #4) > That is what the patch I provided fixed. perhaps you did not add that? > http://dev.gentoo.org/~solar/patch_overlay/app-misc/beep/beep-1.2.2-nosuid.patch > > If the ioctl can't happen a classic \a beep is printed. The patch is definitely applied, but it doesn't produce an \a even when the ioctl fails: open("/dev/console", O_WRONLY) = 3 ioctl(3, KIOCSOUND, 0xa97) = -1 EPERM (Operation not permitted) nanosleep({0, 200000000}, NULL) = 0 ioctl(3, KIOCSOUND, 0) = -1 EPERM (Operation not permitted) close(3) = 0 exit_group(0) = ? Either way, this probably needs a helping hand from udev, because the primary problem is that /dev/console is 0600, so only root can access it.
no i changed the permissions, infact in the 2nd part of my bug report you can see that console access is allowed, so the problem was only on ioctl
hrmm. I'm not sure why your user is allowed to open() /dev/console at all. That is a priv that is supposed to be limited to the root user. You/We may have bigger problems. Example: strace -o /dev/stdout -eopen -f cat /dev/console | grep /dev/con 16642 open("/dev/console", O_RDONLY|O_LARGEFILE) = -1 EACCES (Permission denied) cat: /dev/console: Permission denied
I could rework the patch to have a fall back handler if you can open /dev/console but the ioctl() fails if you want slarti. But I'm pretty sure that we should not be able to open that device nod as non root.
ok, so a suid (or sudo hack) will be the only solution
(In reply to comment #10) > ok, so a suid (or sudo hack) will be the only solution Or unbreak your /dev/console permissions
Okay, well this is fixed. It works fine for me in X and everything now. Stupid thing was, my bell was plugged in one pin along, so wasn't making any sound. After I double checked this morning I realised and moved it back across. I'm resolving this bug as invalid, because I can't reproduce any problem -- Patrizio, check your terminal doesn't do visual bells on \a or anything like that. Sorry for the hassle (and premature conclusions) solar, and thanks for comments.
seems you're right! but the strange thing is it worked once...and now not! from tty it works from user too, from X i can't. using xterm and konsole and gnome-terminal. what should i do? i'm in a kde 3.5 session
(In reply to comment #13) > seems you're right! > > but the strange thing is it worked once...and now not! > > from tty it works from user too, from X i can't. > using xterm and konsole and gnome-terminal. what should i do? > > i'm in a kde 3.5 session > Don't know about konsole or KDE. Make sure "Terminal Bell" is selected in the gnome-terminal preferences.
it is...but with no luck. same in konsole
try "xset b on".
nothing to do!