~mathiaz/ubuntu/lucid/mysql-dfsg-5.1/zap-bug-552053

« back to all changes in this revision

Viewing changes to cmd-line-utils/libedit/tty.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (1.1.2 upstream) (0.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090625125545-m8ogs96zzsri74xe
Tags: 5.1.34-1ubuntu1
* Merge from debian experimental (and 5.0 from main), remaining changes:
  - debian/mysql-server-5.1.config:
    + ask for MySQL root password at priority high instead of medium so
      that the password prompt is seen on a default install. (LP: #319843)
    + don't ask for root password when upgrading from a 5.0 install.
  - debian/control:
    + Make libmysqlclient16-dev a transitional package depending on
      libmysqlclient-dev.
    + Make libmysqlclient-dev conflict with libmysqlclient15-dev.
    + Don't build mysql-server, mysql-client, mysql-common and
      libmysqlclient15-dev binary packages since they're still provided
      by mysql-dfsg-5.0.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in
      a full MTA on all installs of mysql-server. (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
    + install mysql-test and sql-bench to /usr/share/mysql/ rather than
      /usr/.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    - debian/apparmor-profile: apparmor profile.
    - debian/rules, debian/mysql-server-5.0.files: install apparmor profile.
    - debian/mysql-server-5.0.dirs: add etc/apparmor.d/force-complain
    - debian/mysql-server-5.0.postrm: remove symlink in force-complain/ on
      purge.
    - debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    - debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    - debian/mysql-server-5.1.postinst: reload apparmor profiles.
  - debian/additions/my.cnf: remove language option. Error message files are
    located in a different directory in MySQL 5.0. Setting the language
    option to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1
    use a default value that works. (LP: #316974)
  - debian/mysql-server-5.1.mysql.init:
    + Clearly indicate that we do not support running multiple instances
      of mysqld by duplicating the init script.
      (closes: #314785, #324834, #435165, #444216)
    + Properly parameterize all existing references to the mysql config
      file (/etc/mysql/my.cnf).
  - debian/mysql-server-5.0.postinst: Clear out the second password
    when setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package.
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - Don't package sql-bench and mysql-test file.
* Dropped changes:
  - debian/patches/92_ssl_test_cert.dpatch: certificate expiration in
    test suite (LP: #323755). Included upstream.
* Dropped from 5.0:
  - apparmor profile:
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6. All version
      of apparmor-profile (>hardy) are higher than this version.
    - debian/mysql-server-5.0.preinst: create symlink for force-complain/
      on pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where the profile
      doesn't exist. Support for pre-hardy upgrades is no longer needed.
* debian/mysql-server-5.1.postinst: fix debian-sys-maint user creation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*      $NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp $ */
 
1
/*      $NetBSD: tty.c,v 1.28 2009/02/06 19:53:23 sketch Exp $  */
2
2
 
3
3
/*-
4
4
 * Copyright (c) 1992, 1993
32
32
 * SUCH DAMAGE.
33
33
 */
34
34
 
35
 
#include <config.h>
 
35
#include "config.h"
 
36
#if !defined(lint) && !defined(SCCSID)
 
37
#if 0
 
38
static char sccsid[] = "@(#)tty.c       8.1 (Berkeley) 6/4/93";
 
39
#else
 
40
#endif
 
41
#endif /* not lint && not SCCSID */
36
42
 
37
43
/*
38
44
 * tty.c: tty interface stuff
39
45
 */
40
46
#include <assert.h>
 
47
#include <errno.h>
41
48
#include "tty.h"
42
49
#include "el.h"
43
50
 
44
51
typedef struct ttymodes_t {
45
52
        const char *m_name;
46
 
        u_int m_value;
 
53
        unsigned int m_value;
47
54
        int m_type;
48
55
}          ttymodes_t;
49
56
 
438
445
 
439
446
 
440
447
 
441
 
#define tty_getty(el, td)       tcgetattr((el)->el_infd, (td))
442
 
#define tty_setty(el, td)       tcsetattr((el)->el_infd, TCSADRAIN, (td))
443
 
 
444
448
#define tty__gettabs(td)        ((((td)->c_oflag & TAB3) == TAB3) ? 0 : 1)
445
449
#define tty__geteightbit(td)    (((td)->c_cflag & CSIZE) == CS8)
446
450
#define tty__cooked_mode(td)    ((td)->c_lflag & ICANON)
447
451
 
 
452
private int     tty_getty(EditLine *, struct termios *);
 
453
private int     tty_setty(EditLine *, int, const struct termios *);
448
454
private int     tty__getcharindex(int);
449
455
private void    tty__getchar(struct termios *, unsigned char *);
450
456
private void    tty__setchar(struct termios *, unsigned char *);
453
459
 
454
460
#define t_qu    t_ts
455
461
 
 
462
/* tty_getty():
 
463
 *      Wrapper for tcgetattr to handle EINTR
 
464
 */
 
465
private int
 
466
tty_getty(EditLine *el, struct termios *t)
 
467
{
 
468
        int rv;
 
469
        while ((rv = tcgetattr(el->el_infd, t)) == -1 && errno == EINTR)
 
470
                continue;
 
471
        return rv;
 
472
}
 
473
 
 
474
/* tty_setty():
 
475
 *      Wrapper for tcsetattr to handle EINTR
 
476
 */
 
477
private int
 
478
tty_setty(EditLine *el, int action, const struct termios *t)
 
479
{
 
480
        int rv;
 
481
        while ((rv = tcsetattr(el->el_infd, action, t)) == -1 && errno == EINTR)
 
482
                continue;
 
483
        return rv;
 
484
}
456
485
 
457
486
/* tty_setup():
458
487
 *      Get the tty parameters and initialize the editing state
514
543
                                            el->el_tty.t_c[TS_IO][rst];
515
544
                }
516
545
                tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
517
 
                if (tty_setty(el, &el->el_tty.t_ex) == -1) {
 
546
                if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
518
547
#ifdef DEBUG_TTY
519
548
                        (void) fprintf(el->el_errfile,
520
549
                            "tty_setup: tty_setty: %s\n",
522
551
#endif /* DEBUG_TTY */
523
552
                        return (-1);
524
553
                }
525
 
        } else
 
554
        }
 
555
#ifdef notdef
 
556
        else
526
557
                tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
 
558
#endif
527
559
 
528
560
        el->el_tty.t_ed.c_iflag &= ~el->el_tty.t_t[ED_IO][MD_INP].t_clrmask;
529
561
        el->el_tty.t_ed.c_iflag |= el->el_tty.t_t[ED_IO][MD_INP].t_setmask;
1040
1072
                        }
1041
1073
                }
1042
1074
        }
1043
 
        if (tty_setty(el, &el->el_tty.t_ed) == -1) {
 
1075
        if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
1044
1076
#ifdef DEBUG_TTY
1045
1077
                (void) fprintf(el->el_errfile, "tty_rawmode: tty_setty: %s\n",
1046
1078
                    strerror(errno));
1065
1097
        if (el->el_flags & EDIT_DISABLED)
1066
1098
                return (0);
1067
1099
 
1068
 
        if (tty_setty(el, &el->el_tty.t_ex) == -1) {
 
1100
        if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
1069
1101
#ifdef DEBUG_TTY
1070
1102
                (void) fprintf(el->el_errfile,
1071
1103
                    "tty_cookedmode: tty_setty: %s\n",
1101
1133
        el->el_tty.t_qu.c_lflag &= ~el->el_tty.t_t[QU_IO][MD_LIN].t_clrmask;
1102
1134
        el->el_tty.t_qu.c_lflag |= el->el_tty.t_t[QU_IO][MD_LIN].t_setmask;
1103
1135
 
1104
 
        if (tty_setty(el, &el->el_tty.t_qu) == -1) {
 
1136
        if (tty_setty(el, TCSADRAIN, &el->el_tty.t_qu) == -1) {
1105
1137
#ifdef DEBUG_TTY
1106
1138
                (void) fprintf(el->el_errfile, "QuoteModeOn: tty_setty: %s\n",
1107
1139
                    strerror(errno));
1122
1154
 
1123
1155
        if (el->el_tty.t_mode != QU_IO)
1124
1156
                return (0);
1125
 
        if (tty_setty(el, &el->el_tty.t_ed) == -1) {
 
1157
        if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) {
1126
1158
#ifdef DEBUG_TTY
1127
1159
                (void) fprintf(el->el_errfile, "QuoteModeOff: tty_setty: %s\n",
1128
1160
                    strerror(errno));
1193
1225
                                st = len =
1194
1226
                                    strlen(el->el_tty.t_t[z][m->m_type].t_name);
1195
1227
                        }
1196
 
                        x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
1197
 
                            ?  '+' : '\0';
1198
 
                        x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
1199
 
                            ? '-' : x;
 
1228
                        if (i != -1) {
 
1229
                            x = (el->el_tty.t_t[z][i].t_setmask & m->m_value)
 
1230
                                ?  '+' : '\0';
 
1231
                            x = (el->el_tty.t_t[z][i].t_clrmask & m->m_value)
 
1232
                                ? '-' : x;
 
1233
                        } else {
 
1234
                            x = '\0';
 
1235
                        }
1200
1236
 
1201
1237
                        if (x != '\0' || aflag) {
1202
1238
 
1221
1257
                return (0);
1222
1258
        }
1223
1259
        while (argv && (s = *argv++)) {
1224
 
                char *p;
 
1260
                const char *p;
1225
1261
                switch (*s) {
1226
1262
                case '+':
1227
1263
                case '-':
1232
1268
                        break;
1233
1269
                }
1234
1270
                d = s;
1235
 
                if ((p = strchr(s, '=')) != NULL)
1236
 
                        *p++ = '\0';
 
1271
                p = strchr(s, '=');
1237
1272
                for (m = ttymodes; m->m_name; m++)
1238
 
                        if (strcmp(m->m_name, d) == 0 &&
 
1273
                        if ((p ? strncmp(m->m_name, d, (size_t)(p - d)) :
 
1274
                            strcmp(m->m_name, d)) == 0 &&
1239
1275
                            (p == NULL || m->m_type == MD_CHAR))
1240
1276
                                break;
1241
1277
 
1246
1282
                }
1247
1283
                if (p) {
1248
1284
                        int c = ffs((int)m->m_value);
1249
 
                        int v = *p ? parse__escape((const char **const) &p) :
 
1285
                        int v = *++p ? parse__escape((const char **) &p) :
1250
1286
                            el->el_tty.t_vdisable;
1251
1287
                        assert(c-- != 0);
1252
1288
                        c = tty__getcharindex(c);
1269
1305
                        break;
1270
1306
                }
1271
1307
        }
 
1308
 
 
1309
        if (el->el_tty.t_mode == z) {
 
1310
                if (tty_setty(el, TCSADRAIN, tios) == -1) {
 
1311
#ifdef DEBUG_TTY
 
1312
                        (void) fprintf(el->el_errfile,
 
1313
                            "tty_stty: tty_setty: %s\n", strerror(errno));
 
1314
#endif /* DEBUG_TTY */
 
1315
                        return (-1);
 
1316
                }
 
1317
        }
 
1318
 
1272
1319
        return (0);
1273
1320
}
1274
1321