Mercurial > mplayer.hg
annotate fibmap_mplayer.c @ 11588:bd910f698b8d
reorganization of subtitles and osd section, removed repeating lines, patch by me and Torinthiel
author | paszczi |
---|---|
date | Mon, 08 Dec 2003 17:40:41 +0000 |
parents | b48d7fca8c73 |
children |
rev | line source |
---|---|
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
1973
diff
changeset
|
1 /* (C)2001,2002 by LGB (Gábor Lénárt), lgb@lgb.hu |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
1973
diff
changeset
|
2 Part of MPlayer project, this source is copyrighted according to GNU/GPL. */ |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
1973
diff
changeset
|
3 |
1164
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
4 #include <stdio.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
5 #include <stdlib.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
6 #include <string.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
7 #include <unistd.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
8 #include <fcntl.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
9 #include <errno.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
10 #include <sys/types.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
11 #include <sys/ioctl.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
12 #include <sys/stat.h> |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
13 |
11578
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
14 #include "mp_msg.h" |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
15 |
1164
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
16 #ifndef FIBMAP |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
17 #define FIBMAP 1 |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
18 #endif |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
19 |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
20 int main ( int argc , char ** argv ) |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
21 { |
11578
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
22 int fd,ret,lba=0; |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
23 if (geteuid()!=0) { |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
24 mp_msg(MSGT_CPLAYER,MSGL_FATAL, "%s must be setuid root to work\n", |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
25 argv[0]); |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
26 return 1; |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
27 } |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
28 if (seteuid(getuid()) == -1) { |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
29 mp_msg(MSGT_CPLAYER,MSGL_FATAL, "Couldn't drop privileges: %s\n", |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
30 strerror(errno)); |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
31 return 1; |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
32 } |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
33 if (argc!=2 || argv[1]==NULL) { |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
34 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"Usage: %s <filename>\n", argv[0]); |
1164
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
35 return 1; |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
36 } |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
37 if ((fd = open(argv[1], O_RDONLY)) == -1) { |
11578
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
38 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"Cannot open file %s: %s\n", |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
39 argv[1], strerror(errno)); |
1164
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
40 return 1; |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
41 } |
11578
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
42 if (seteuid(0) == -1) { |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
43 mp_msg(MSGT_CPLAYER,MSGL_FATAL, "Couldn't restore root privileges: %s\n", |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
44 strerror(errno)); |
1164
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
45 return 1; |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
46 } |
11578
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
47 ret = ioctl(fd, FIBMAP, &lba); |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
48 if (seteuid(getuid()) == -1) { |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
49 mp_msg(MSGT_CPLAYER,MSGL_FATAL, "Couldn't re-drop privileges: %s\n", |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
50 strerror(errno)); |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
51 return 1; |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
52 } |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
53 close(fd); |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
54 if (ret != 0) { |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
55 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"fibmap ioctl failed: %s\n", |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
56 strerror(errno)); |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
57 return 1; |
b48d7fca8c73
Security fixes for fibmap_mplayer by Adam Rice <adamrice@ntlworld.com>
attila
parents:
3975
diff
changeset
|
58 } |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
1973
diff
changeset
|
59 printf("%d\n",lba); |
1164
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
60 return 0; |
3367eba48763
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)
lgb
parents:
diff
changeset
|
61 } |