Jim Tcl
Check-in [256d17bf10]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:aio: No need to create a new channel for ssl

Just "promote" the current channel to ssl

Signed-off-by: Steve Bennett <steveb@workware.net.au>

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 256d17bf101d8c066cc41e5c929a423bce8e4593
User & Date: steveb@workware.net.au 2017-10-21 02:49:17
Context
2017-10-21
03:25
tests: Use a more explicit approach to test SIGPIPE

Write to a closed pipe in exec2-3.2 to force SIGPIPE

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: b1f8a31bdc user: steveb@workware.net.au tags: trunk

02:49
aio: No need to create a new channel for ssl

Just "promote" the current channel to ssl

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 256d17bf10 user: steveb@workware.net.au tags: trunk

02:49
doc: Update remaining references to os.wait

Now simply 'wait'

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 6f79baf755 user: steveb@workware.net.au tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jim-aio.c.

1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209

1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
....
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255



1256
1257
1258
1259
1260
1261
1262
1263

1264
1265
1266
1267
1268
1269
1270

#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP)
static int aio_cmd_ssl(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    AioFile *af = Jim_CmdPrivData(interp);
    SSL *ssl;
    SSL_CTX *ssl_ctx;
    int fd, server = 0;

    if (argc == 5) {
        if (!Jim_CompareStringImmediate(interp, argv[2], "-server")) {
            return JIM_ERR;
        }
        server = 1;
    }
    else if (argc != 2) {
        Jim_WrongNumArgs(interp, 2, argv, "?-server cert priv?");
        return JIM_ERR;
    }

    fd = fileno(af->fp);
#if defined(HAVE_DUP)
    fd = dup(fd);
    if (fd < 0) {
        return JIM_ERR;
    }
#endif

    ssl_ctx = JimAioSslCtx(interp);
    if (ssl_ctx == NULL) {
        return JIM_ERR;
    }

    ssl = SSL_new(ssl_ctx);
    if (ssl == NULL) {
#if defined(HAVE_DUP)
        close(fd);
#endif
        Jim_SetResultString(interp, ERR_error_string(ERR_get_error(), NULL), -1);
        return JIM_ERR;
    }

    SSL_set_cipher_list(ssl, "ALL");

    if (SSL_set_fd(ssl, fileno(af->fp)) == 0) {
        goto out;
    }
................................................................................
    }
    else {
        if (SSL_connect(ssl) != 1) {
            goto out;
        }
    }

    af = JimMakeChannel(interp, NULL, fd, NULL, "aio.sslstream%ld", af->addr_family, "r+");
    if (af == NULL) {
        goto out;
    }

    af->ssl = ssl;
    af->fops = &ssl_fops;




    return JIM_OK;

out:
#if defined(HAVE_DUP)
    close(fd);
#endif
    SSL_free(ssl);

    Jim_SetResultString(interp, ERR_error_string(ERR_get_error(), NULL), -1);
    return JIM_ERR;
}

static int aio_cmd_verify(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    AioFile *af = Jim_CmdPrivData(interp);







|












|
|
<
<


<
>







|
<
<
<
<







 







<
<
<
<
<


>
>
>




|
<
<
|
>







1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204


1205
1206

1207
1208
1209
1210
1211
1212
1213
1214
1215




1216
1217
1218
1219
1220
1221
1222
....
1236
1237
1238
1239
1240
1241
1242





1243
1244
1245
1246
1247
1248
1249
1250
1251
1252


1253
1254
1255
1256
1257
1258
1259
1260
1261

#if defined(JIM_SSL) && !defined(JIM_BOOTSTRAP)
static int aio_cmd_ssl(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    AioFile *af = Jim_CmdPrivData(interp);
    SSL *ssl;
    SSL_CTX *ssl_ctx;
    int server = 0;

    if (argc == 5) {
        if (!Jim_CompareStringImmediate(interp, argv[2], "-server")) {
            return JIM_ERR;
        }
        server = 1;
    }
    else if (argc != 2) {
        Jim_WrongNumArgs(interp, 2, argv, "?-server cert priv?");
        return JIM_ERR;
    }

    if (af->ssl) {
        Jim_SetResultFormatted(interp, "%#s: stream is already ssl", argv[0]);


        return JIM_ERR;
    }


    ssl_ctx = JimAioSslCtx(interp);
    if (ssl_ctx == NULL) {
        return JIM_ERR;
    }

    ssl = SSL_new(ssl_ctx);
    if (ssl == NULL) {
        goto out;




    }

    SSL_set_cipher_list(ssl, "ALL");

    if (SSL_set_fd(ssl, fileno(af->fp)) == 0) {
        goto out;
    }
................................................................................
    }
    else {
        if (SSL_connect(ssl) != 1) {
            goto out;
        }
    }






    af->ssl = ssl;
    af->fops = &ssl_fops;

    /* Set the command name as the result */
    Jim_SetResult(interp, argv[0]);

    return JIM_OK;

out:
    if (ssl) {


        SSL_free(ssl);
    }
    Jim_SetResultString(interp, ERR_error_string(ERR_get_error(), NULL), -1);
    return JIM_ERR;
}

static int aio_cmd_verify(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    AioFile *af = Jim_CmdPrivData(interp);

Changes to jim_tcl.txt.

4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
    +*vmin* 'numchars'+;;
		Minimum number of characters to read.

    +*vtime* 'time'+;;
		Timeout for noncanonical read (units of 0.1 seconds)

+$handle *ssl* *?-server cert priv?*+::
    Initiates a SSL/TLS session and returns a new stream

+$handle *unlock*+::
    Release a POSIX lock previously acquired by `aio lock`.

+$handle *verify*+::
    Verifies the certificate of a SSL/TLS stream peer








|







4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
    +*vmin* 'numchars'+;;
		Minimum number of characters to read.

    +*vtime* 'time'+;;
		Timeout for noncanonical read (units of 0.1 seconds)

+$handle *ssl* *?-server cert priv?*+::
    Upgrades the stream to a SSL/TLS session and returns the handle.

+$handle *unlock*+::
    Release a POSIX lock previously acquired by `aio lock`.

+$handle *verify*+::
    Verifies the certificate of a SSL/TLS stream peer