directvt / vtm

Text-based desktop environment
MIT License
1.62k stars 43 forks source link

doskey is not working #428

Closed AloisKraus closed 1 year ago

AloisKraus commented 1 year ago

When having a file with doskey macros

keys.txt

k1=echo hi
k2=echo hi2

doskey /macrofile=keys.txt and then list the defined ones the list comes back empty when running vtm inside Windows Terminal:

With vtm image

when doing this in a Windows Terminal cmd prompt then it works

With cmd.exe image

No errors. That is really strange.

o-sdn-o commented 1 year ago

TL/DR: This behavior is intentional. So far this doesn't work.

I haven't yet implemented DOSKEY functionality because it seemed to me to be a significant security flaw. DOSKEY (1989 A.D.) was invented and implemented for single user operating systems such as DR-DOS/MS-DOS/PC DOS, where there were no concepts of roles/rights, etc. Subsequently, in the Windows system, this functionality was moved up to the wrong security level, allowing any application to gain unauthorized access to sensitive data such as command history and allowing command name spoofing.

Despite the fact that Wikipedia says that this functionality is integrated into CMD.EXE, it is not. This is entirely outside of CMD.EXE, as you can see.

In fact, this functionality is not difficult to implement, but it should be further (and more thoroughly) investigated for security issues.

Everything related to aliases and command history is disabled for now. The following Win32 Console APIs are silently (w/o errors) disabled:

AloisKraus commented 1 year ago

While you are right it might be a security flaw many developer environments set them. It is unfortunate that I cannot use vtm in developer shells. As long not everyone is using Windows Terminal there is not much we could use for cmd shell scripting.

o-sdn-o commented 1 year ago

We can make this configurable and off by default.

AloisKraus commented 1 year ago

That would be a great addition!

o-sdn-o commented 1 year ago

I have now realized that this is vital functionality, and it must be implemented unconditionally.

o-sdn-o commented 1 year ago

I implemented the DOSKEY functionality. You can test the branch from the pull request. I'll publish a release a little later.

AloisKraus commented 1 year ago

Thanks. The test build looks good. Doskey macros are showing up now. Thanks!

AloisKraus commented 1 year ago

My environment has VS2019, VS2022, VS2022 Preview, and VS2017 Build tools. Looks like cmake did create a solution which did target VS2019. It was targetting Build Tools 14.3, but these were not installed.

AloisKraus commented 1 year ago

I have noticed that the new vtm when started from a Windows Terminal Session with a cmd shell

vtm -r
Not enough memory resources are available to process this command.

is showing up. The old VTM did not have this warning.

o-sdn-o commented 1 year ago

Not enough memory resources are available to process this command.

This issue may be related to the fact that when running vtm -r it requests the current window title and on the first request it received an empty line. I have corrected this bug by https://github.com/o-sdn-o/vtm/commit/be95d9c2d7e2d160478b3befef5ea94253325d70 .

Can you please test it for this issue? (auto binaries in the pull request are updated)