Skip to content
Snippets Groups Projects
Commit 88d0c30c authored by deuce's avatar deuce
Browse files

Add a patch to allow setting the terminal type and size.

The access paramter to the ACL is bogus, but it works.
parent c30af2f6
Branches
Tags
No related merge requests found
......@@ -27,6 +27,10 @@ ifeq ($(shell perl -e 'print "$(machine)"=~/\.arm/?"YES":"NO"'),YES)
endif
endif
.PHONY: cryptlib libmozjs
cryptlib: $(CRYPTLIB_BUILD)
libmozjs: $(JSLIB_BUILD)
###############
# Directories #
###############
......@@ -68,6 +72,7 @@ $(CRYPTLIB_BUILD): $(3RDP_ROOT)$(DIRSEP)dist/cryptlib.zip $(3RDP_ROOT)$(DIRSEP)b
$(QUIET)patch -p0 -d $(CRYPT_SRC) < random_exit.patch
$(QUIET)patch -p0 -d $(CRYPT_SRC) < SSL-fix.patch
$(QUIET)patch -p0 -d $(CRYPT_SRC) < Dynamic-linked-static-lib.patch
$(QUIET)patch -p0 -d $(CRYPT_SRC) < terminal-params.patch
$(QUIET)cd $(CRYPT_SRC) && env - PATH=$(PATH) make
$(QUIET)cp $(CRYPT_SRC)$(DIRSEP)libcl.a $(CRYPT_IDIR)
$(QUIET)cp $(CRYPT_SRC)$(DIRSEP)cryptlib.h $(CRYPT_IDIR)
diff -ur ../cl.patched/cryptapi.c ./cryptapi.c
--- ../cl.patched/cryptapi.c 2014-06-20 12:40:45.000000000 -0700
+++ ./cryptapi.c 2014-06-20 19:11:53.000000000 -0700
@@ -1060,6 +1060,7 @@
}
else
{
+fprintf(stderr, "That's weird\n");
if( cmd->strArgLen[ 0 ] < 1 || \
cmd->strArgLen[ 0 ] >= MAX_ATTRIBUTE_SIZE )
return( CRYPT_ARGERROR_NUM2 );
@@ -1079,6 +1080,7 @@
( MESSAGE_CAST ) &cmd->arg[ 2 ],
cmd->arg[ 1 ] ) );
}
+fprintf(stderr, "First one\n");
return( krnlSendMessage( cmd->arg[ 0 ], MESSAGE_SETATTRIBUTE,
( MESSAGE_CAST ) &cmd->arg[ 2 ], cmd->arg[ 1 ] ) );
}
@@ -1089,6 +1091,7 @@
IMESSAGE_SETATTRIBUTE_S, &msgData,
cmd->arg[ 1 ] ) );
}
+fprintf(stderr, "Last one\n");
return( krnlSendMessage( cmd->arg[ 0 ], MESSAGE_SETATTRIBUTE_S,
&msgData, cmd->arg[ 1 ] ) );
}
@@ -2558,9 +2561,11 @@
/* Perform basic client-side error checking */
if( !isHandleRangeValid( cryptHandle ) && cryptHandle != CRYPT_UNUSED )
return( CRYPT_ERROR_PARAM1 );
+fprintf(stderr, "Checking\n");
if( attributeType <= CRYPT_ATTRIBUTE_NONE || \
attributeType >= CRYPT_ATTRIBUTE_LAST )
return( CRYPT_ERROR_PARAM2 );
+fprintf(stderr, "Good\n");
if( !isReadPtrConst( value, 1 ) )
return( CRYPT_ERROR_PARAM3 );
if( attributeType == CRYPT_CTXINFO_KEY_COMPONENTS )
@@ -2671,6 +2676,7 @@
cmd.strArg[ 0 ] = ( void * ) value;
cmd.strArgLen[ 0 ] = length;
status = DISPATCH_COMMAND( cmdSetAttribute, cmd );
+fprintf(stderr, "Dispatched return: %d\n", status);
if( cryptStatusOK( status ) )
return( CRYPT_OK );
return( mapError( errorMap, FAILSAFE_ARRAYSIZE( errorMap, ERRORMAP ),
diff -ur ../cl.patched/cryptlib.h ./cryptlib.h
--- ../cl.patched/cryptlib.h 2014-06-20 12:40:45.000000000 -0700
+++ ./cryptlib.h 2014-06-20 12:47:00.000000000 -0700
@@ -1237,6 +1237,11 @@
CRYPT_SESSINFO_SSL_OPTIONS, /* SSL/TLS protocol options */
CRYPT_SESSINFO_TSP_MSGIMPRINT, /* TSP message imprint */
+ /* Terminal attributes */
+ CRYPT_SESSINFO_SSH_TERMINAL, /* TERM string sent to remote */
+ CRYPT_SESSINFO_SSH_WIDTH, /* Terminal width */
+ CRYPT_SESSINFO_SSH_HEIGHT, /* Terminal height */
+
/* Used internally */
CRYPT_SESSINFO_LAST, CRYPT_USERINFO_FIRST = 7000,
diff -ur ../cl.patched/kernel/attr_acl.c ./kernel/attr_acl.c
--- ../cl.patched/kernel/attr_acl.c 2014-06-20 12:40:39.000000000 -0700
+++ ./kernel/attr_acl.c 2014-06-20 20:32:54.000000000 -0700
@@ -3742,6 +3742,25 @@
MKPERM_TSP( xWD_xWD ),
ROUTE( OBJECT_TYPE_SESSION ), &objectCtxHash ),
+ MKACL_S( /* SSH client: Read/write */
+ CRYPT_SESSINFO_SSH_TERMINAL,
+ ST_NONE, ST_NONE, ST_SESS_SSH,
+ 0xffffffff /*MKPERM_SSH_EXT( RWD_RWD )*/,
+ ROUTE( OBJECT_TYPE_SESSION ),
+ RANGE( 1, CRYPT_MAX_TEXTSIZE ) ),
+ MKACL_N( /* SSH client: Read/write */
+ CRYPT_SESSINFO_SSH_WIDTH,
+ ST_NONE, ST_NONE, ST_SESS_SSH,
+ 0xffffffff /*MKPERM_SSH_EXT( RWD_RWD )*/,
+ ROUTE( OBJECT_TYPE_SESSION ),
+ RANGE( 1, 800 ) ),
+ MKACL_N( /* SSH client: Read/write */
+ CRYPT_SESSINFO_SSH_HEIGHT,
+ ST_NONE, ST_NONE, ST_SESS_SSH,
+ 0xffffffff /*MKPERM_SSH_EXT( RWD_RWD )*/,
+ ROUTE( OBJECT_TYPE_SESSION ),
+ RANGE( 1, 800 ) ),
+
MKACL_END(), MKACL_END()
};
diff -ur ../cl.patched/session/sess_attr.c ./session/sess_attr.c
--- ../cl.patched/session/sess_attr.c 2014-06-20 12:40:41.000000000 -0700
+++ ./session/sess_attr.c 2014-06-20 20:33:27.000000000 -0700
@@ -323,6 +323,8 @@
TRUE : FALSE;
return( CRYPT_OK );
+ case CRYPT_SESSINFO_SSH_WIDTH:
+ case CRYPT_SESSINFO_SSH_HEIGHT:
case CRYPT_SESSINFO_SERVER_PORT:
case CRYPT_SESSINFO_CLIENT_PORT:
{
@@ -392,6 +394,7 @@
return( CRYPT_ERROR_NOTFOUND );
}
+ case CRYPT_SESSINFO_SSH_TERMINAL:
case CRYPT_SESSINFO_USERNAME:
case CRYPT_SESSINFO_PASSWORD:
case CRYPT_SESSINFO_SERVER_FINGERPRINT:
@@ -532,6 +535,13 @@
return( status );
}
+ case CRYPT_SESSINFO_SSH_WIDTH:
+ return( addSessionInfo( &sessionInfoPtr->attributeList,
+ CRYPT_SESSINFO_SSH_WIDTH, value ) );
+ case CRYPT_SESSINFO_SSH_HEIGHT:
+ return( addSessionInfo( &sessionInfoPtr->attributeList,
+ CRYPT_SESSINFO_SSH_HEIGHT, value ) );
+
case CRYPT_SESSINFO_SERVER_PORT:
/* If there's already a transport session or network socket
specified then we can't set a port as well */
@@ -883,6 +893,7 @@
attribute, data, dataLength, flags ) );
}
+ case CRYPT_SESSINFO_SSH_TERMINAL:
case CRYPT_SESSINFO_SERVER_FINGERPRINT:
/* Remember the value */
return( addSessionInfoS( &sessionInfoPtr->attributeList,
@@ -938,6 +949,9 @@
sessionInfoPtr->writeTimeout = CRYPT_ERROR;
return( CRYPT_OK );
+ case CRYPT_SESSINFO_SSH_TERMINAL:
+ case CRYPT_SESSINFO_SSH_WIDTH:
+ case CRYPT_SESSINFO_SSH_HEIGHT:
case CRYPT_SESSINFO_USERNAME:
case CRYPT_SESSINFO_PASSWORD:
case CRYPT_SESSINFO_SERVER_NAME:
diff -ur ../cl.patched/session/ssh2_msgc.c ./session/ssh2_msgc.c
--- ../cl.patched/session/ssh2_msgc.c 2014-06-20 12:40:41.000000000 -0700
+++ ./session/ssh2_msgc.c 2014-06-20 20:36:36.000000000 -0700
@@ -447,6 +447,12 @@
CHANNEL_WRITE );
int packetOffset, status;
+ MESSAGE_DATA term;
+ BYTE termString[ CRYPT_MAX_TEXTSIZE + 8 ];
+ int value;
+
+ term.data=termString;
+ term.length=CRYPT_MAX_TEXTSIZE;
assert( isWritePtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isWritePtr( stream, sizeof( STREAM ) ) );
@@ -545,9 +551,18 @@
writeUint32( stream, channelNo );
writeString32( stream, "pty-req", 7 );
sputc( stream, 0 ); /* No reply */
- writeString32( stream, "xterm", 5 );/* Generic */
- writeUint32( stream, 80 );
- writeUint32( stream, 48 ); /* 48 x 80 (24 x 80 is so 1970s) */
+ if( cryptStatusError( status = getSessionAttributeS( sessionInfoPtr, &term, CRYPT_SESSINFO_SSH_TERMINAL) ) )
+ writeString32( stream, "xterm", 5 );/* Generic */
+ else
+ writeString32( stream, term.data, term.length );/* Generic */
+ if( cryptStatusError( getSessionAttribute( sessionInfoPtr, &value, CRYPT_SESSINFO_SSH_WIDTH ) ) )
+ writeUint32( stream, 80 );
+ else
+ writeUint32( stream, value);
+ if( cryptStatusError( getSessionAttribute( sessionInfoPtr, &value, CRYPT_SESSINFO_SSH_HEIGHT ) ) )
+ writeUint32( stream, 48 ); /* 48 x 80 (24 x 80 is so 1970s) */
+ else
+ writeUint32( stream, value);
writeUint32( stream, 0 );
writeUint32( stream, 0 ); /* No graphics capabilities */
status = writeUint32( stream, 0 ); /* No special TTY modes */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment