kbd.c (156126) | kbd.c (164033) |
---|---|
1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/kbd/kbd.c 156126 2006-02-28 23:46:23Z emax $"); | 29__FBSDID("$FreeBSD: head/sys/dev/kbd/kbd.c 164033 2006-11-06 13:42:10Z rwatson $"); |
30 31#include "opt_kbd.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/malloc.h> 37#include <sys/conf.h> 38#include <sys/fcntl.h> 39#include <sys/tty.h> 40#include <sys/poll.h> | 30 31#include "opt_kbd.h" 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/malloc.h> 37#include <sys/conf.h> 38#include <sys/fcntl.h> 39#include <sys/tty.h> 40#include <sys/poll.h> |
41#include <sys/priv.h> |
|
41#include <sys/proc.h> 42#include <sys/sysctl.h> 43#include <sys/uio.h> 44 45#include <sys/kbio.h> 46 47#include <dev/kbd/kbdreg.h> 48 --- 918 unchanged lines hidden (view full) --- 967 /* Low keymap_restrict_change means any changes are OK. */ 968 if (keymap_restrict_change <= 0) 969 return (0); 970 971 /* High keymap_restrict_change means only root can change the keymap. */ 972 if (keymap_restrict_change >= 2) { 973 for (i = 0; i < NUM_STATES; i++) 974 if (oldkey->map[i] != newkey->map[i]) | 42#include <sys/proc.h> 43#include <sys/sysctl.h> 44#include <sys/uio.h> 45 46#include <sys/kbio.h> 47 48#include <dev/kbd/kbdreg.h> 49 --- 918 unchanged lines hidden (view full) --- 968 /* Low keymap_restrict_change means any changes are OK. */ 969 if (keymap_restrict_change <= 0) 970 return (0); 971 972 /* High keymap_restrict_change means only root can change the keymap. */ 973 if (keymap_restrict_change >= 2) { 974 for (i = 0; i < NUM_STATES; i++) 975 if (oldkey->map[i] != newkey->map[i]) |
975 return suser(td); | 976 return priv_check(td, PRIV_KEYBOARD); |
976 if (oldkey->spcl != newkey->spcl) | 977 if (oldkey->spcl != newkey->spcl) |
977 return suser(td); | 978 return priv_check(td, PRIV_KEYBOARD); |
978 if (oldkey->flgs != newkey->flgs) | 979 if (oldkey->flgs != newkey->flgs) |
979 return suser(td); | 980 return priv_check(td, PRIV_KEYBOARD); |
980 return (0); 981 } 982 983 /* Otherwise we have to see if any special keys are being changed. */ 984 for (i = 0; i < NUM_STATES; i++) { 985 /* 986 * If either the oldkey or the newkey action is restricted 987 * then we must make sure that the action doesn't change. 988 */ 989 if (!RESTRICTED_KEY(oldkey, i) && !RESTRICTED_KEY(newkey, i)) 990 continue; 991 if ((oldkey->spcl & (0x80 >> i)) == (newkey->spcl & (0x80 >> i)) 992 && oldkey->map[i] == newkey->map[i]) 993 continue; | 981 return (0); 982 } 983 984 /* Otherwise we have to see if any special keys are being changed. */ 985 for (i = 0; i < NUM_STATES; i++) { 986 /* 987 * If either the oldkey or the newkey action is restricted 988 * then we must make sure that the action doesn't change. 989 */ 990 if (!RESTRICTED_KEY(oldkey, i) && !RESTRICTED_KEY(newkey, i)) 991 continue; 992 if ((oldkey->spcl & (0x80 >> i)) == (newkey->spcl & (0x80 >> i)) 993 && oldkey->map[i] == newkey->map[i]) 994 continue; |
994 return suser(td); | 995 return priv_check(td, PRIV_KEYBOARD); |
995 } 996 997 return (0); 998} 999 1000static int 1001keymap_change_ok(keymap_t *oldmap, keymap_t *newmap, struct thread *td) 1002{ --- 12 unchanged lines hidden (view full) --- 1015{ 1016 struct acc_t *oldacc, *newacc; 1017 int accent, i; 1018 1019 if (keymap_restrict_change <= 2) 1020 return (0); 1021 1022 if (oldmap->n_accs != newmap->n_accs) | 996 } 997 998 return (0); 999} 1000 1001static int 1002keymap_change_ok(keymap_t *oldmap, keymap_t *newmap, struct thread *td) 1003{ --- 12 unchanged lines hidden (view full) --- 1016{ 1017 struct acc_t *oldacc, *newacc; 1018 int accent, i; 1019 1020 if (keymap_restrict_change <= 2) 1021 return (0); 1022 1023 if (oldmap->n_accs != newmap->n_accs) |
1023 return suser(td); | 1024 return priv_check(td, PRIV_KEYBOARD); |
1024 1025 for (accent = 0; accent < oldmap->n_accs; accent++) { 1026 oldacc = &oldmap->acc[accent]; 1027 newacc = &newmap->acc[accent]; 1028 if (oldacc->accchar != newacc->accchar) | 1025 1026 for (accent = 0; accent < oldmap->n_accs; accent++) { 1027 oldacc = &oldmap->acc[accent]; 1028 newacc = &newmap->acc[accent]; 1029 if (oldacc->accchar != newacc->accchar) |
1029 return suser(td); | 1030 return priv_check(td, PRIV_KEYBOARD); |
1030 for (i = 0; i < NUM_ACCENTCHARS; ++i) { 1031 if (oldacc->map[i][0] != newacc->map[i][0]) | 1031 for (i = 0; i < NUM_ACCENTCHARS; ++i) { 1032 if (oldacc->map[i][0] != newacc->map[i][0]) |
1032 return suser(td); | 1033 return priv_check(td, PRIV_KEYBOARD); |
1033 if (oldacc->map[i][0] == 0) /* end of table */ 1034 break; 1035 if (oldacc->map[i][1] != newacc->map[i][1]) | 1034 if (oldacc->map[i][0] == 0) /* end of table */ 1035 break; 1036 if (oldacc->map[i][1] != newacc->map[i][1]) |
1036 return suser(td); | 1037 return priv_check(td, PRIV_KEYBOARD); |
1037 } 1038 } 1039 1040 return (0); 1041} 1042 1043static int 1044fkey_change_ok(fkeytab_t *oldkey, fkeyarg_t *newkey, struct thread *td) 1045{ 1046 if (keymap_restrict_change <= 3) 1047 return (0); 1048 1049 if (oldkey->len != newkey->flen || 1050 bcmp(oldkey->str, newkey->keydef, oldkey->len) != 0) | 1038 } 1039 } 1040 1041 return (0); 1042} 1043 1044static int 1045fkey_change_ok(fkeytab_t *oldkey, fkeyarg_t *newkey, struct thread *td) 1046{ 1047 if (keymap_restrict_change <= 3) 1048 return (0); 1049 1050 if (oldkey->len != newkey->flen || 1051 bcmp(oldkey->str, newkey->keydef, oldkey->len) != 0) |
1051 return suser(td); | 1052 return priv_check(td, PRIV_KEYBOARD); |
1052 1053 return (0); 1054} 1055#endif 1056 1057/* get a pointer to the string associated with the given function key */ 1058u_char 1059*genkbd_get_fkeystr(keyboard_t *kbd, int fkey, size_t *len) --- 367 unchanged lines hidden --- | 1053 1054 return (0); 1055} 1056#endif 1057 1058/* get a pointer to the string associated with the given function key */ 1059u_char 1060*genkbd_get_fkeystr(keyboard_t *kbd, int fkey, size_t *len) --- 367 unchanged lines hidden --- |