public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 2/2] ShellPkg-Shell App: Provide fully-qualified path to shell scripts
@ 2018-10-24 16:35 Jim.Dailey
  2018-10-24 18:03 ` Carsey, Jaben
  0 siblings, 1 reply; 3+ messages in thread
From: Jim.Dailey @ 2018-10-24 16:35 UTC (permalink / raw)
  To: edk2-devel; +Cc: ruiyu.ni, jaben.carsey

Section 3.6.2 of version 2.2 of the shell specification requires that
the first positional argument (i.e. arg 0) of a shell script resolves
to "the full path name of the script itself."

Ensure that the startup script and any scripts launched by the shell
meet this requirement.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
---
 ShellPkg/Application/Shell/Shell.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 6185b6ac80..fe88177d57 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -3,6 +3,7 @@
 
   Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.<BR>
+  Copyright 2018 Dell Technologies.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -1275,7 +1276,8 @@ DoStartupScript(
 
   FileStringPath = LocateStartupScript (ImagePath, FilePath);
   if (FileStringPath != NULL) {
-    Status = RunScriptFile (FileStringPath, NULL, L"", ShellInfoObject.NewShellParametersProtocol);
+    FileStringPath = FullyQualifyPath(&FileStringPath);
+    Status = RunScriptFile (FileStringPath, NULL, FileStringPath, ShellInfoObject.NewShellParametersProtocol);
     FreePool (FileStringPath);
   } else {
     //
@@ -2474,6 +2476,7 @@ RunCommandOrFile(
       }
       switch (Type) {
         case   Script_File_Name:
+          CommandWithPath = FullyQualifyPath(&CommandWithPath);
           Status = RunScriptFile (CommandWithPath, NULL, CmdLine, ParamProtocol);
           break;
         case   Efi_Application:
@@ -2812,7 +2815,12 @@ RunScriptFileHandle (
       DeleteScriptFileStruct(NewScriptFile);
       return (EFI_OUT_OF_RESOURCES);
     }
-    for (LoopVar = 0 ; LoopVar < 10 && LoopVar < NewScriptFile->Argc; LoopVar++) {
+    //
+    // Put the full path of the script file into Argv[0] as required by section
+    // 3.6.2 of version 2.2 of the shell specification.
+    //
+    NewScriptFile->Argv[0] = StrnCatGrow(&NewScriptFile->Argv[0], NULL, NewScriptFile->ScriptName, 0);
+    for (LoopVar = 1 ; LoopVar < 10 && LoopVar < NewScriptFile->Argc; LoopVar++) {
       ASSERT(NewScriptFile->Argv[LoopVar] == NULL);
       NewScriptFile->Argv[LoopVar] = StrnCatGrow(&NewScriptFile->Argv[LoopVar], NULL, ShellInfoObject.NewShellParametersProtocol->Argv[LoopVar], 0);
       if (NewScriptFile->Argv[LoopVar] == NULL) {
-- 
2.17.0.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] ShellPkg-Shell App: Provide fully-qualified path to shell scripts
  2018-10-24 16:35 [PATCH 2/2] ShellPkg-Shell App: Provide fully-qualified path to shell scripts Jim.Dailey
@ 2018-10-24 18:03 ` Carsey, Jaben
  2018-10-25  5:48   ` Ni, Ruiyu
  0 siblings, 1 reply; 3+ messages in thread
From: Carsey, Jaben @ 2018-10-24 18:03 UTC (permalink / raw)
  To: Jim.Dailey@dell.com, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu

Looks good to me.
Ray?

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

p.s. Ray if you agree you can RB and I will handle the push.

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Jim.Dailey@dell.com
> Sent: Wednesday, October 24, 2018 9:36 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [edk2] [PATCH 2/2] ShellPkg-Shell App: Provide fully-qualified path
> to shell scripts
> Importance: High
> 
> Section 3.6.2 of version 2.2 of the shell specification requires that
> the first positional argument (i.e. arg 0) of a shell script resolves
> to "the full path name of the script itself."
> 
> Ensure that the startup script and any scripts launched by the shell
> meet this requirement.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jim Dailey <jim_dailey@dell.com>
> ---
>  ShellPkg/Application/Shell/Shell.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/Shell.c
> b/ShellPkg/Application/Shell/Shell.c
> index 6185b6ac80..fe88177d57 100644
> --- a/ShellPkg/Application/Shell/Shell.c
> +++ b/ShellPkg/Application/Shell/Shell.c
> @@ -3,6 +3,7 @@
> 
>    Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>    (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.<BR>
> +  Copyright 2018 Dell Technologies.<BR>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD
> License
>    which accompanies this distribution.  The full text of the license may be
> found at
> @@ -1275,7 +1276,8 @@ DoStartupScript(
> 
>    FileStringPath = LocateStartupScript (ImagePath, FilePath);
>    if (FileStringPath != NULL) {
> -    Status = RunScriptFile (FileStringPath, NULL, L"",
> ShellInfoObject.NewShellParametersProtocol);
> +    FileStringPath = FullyQualifyPath(&FileStringPath);
> +    Status = RunScriptFile (FileStringPath, NULL, FileStringPath,
> ShellInfoObject.NewShellParametersProtocol);
>      FreePool (FileStringPath);
>    } else {
>      //
> @@ -2474,6 +2476,7 @@ RunCommandOrFile(
>        }
>        switch (Type) {
>          case   Script_File_Name:
> +          CommandWithPath = FullyQualifyPath(&CommandWithPath);
>            Status = RunScriptFile (CommandWithPath, NULL, CmdLine,
> ParamProtocol);
>            break;
>          case   Efi_Application:
> @@ -2812,7 +2815,12 @@ RunScriptFileHandle (
>        DeleteScriptFileStruct(NewScriptFile);
>        return (EFI_OUT_OF_RESOURCES);
>      }
> -    for (LoopVar = 0 ; LoopVar < 10 && LoopVar < NewScriptFile->Argc;
> LoopVar++) {
> +    //
> +    // Put the full path of the script file into Argv[0] as required by section
> +    // 3.6.2 of version 2.2 of the shell specification.
> +    //
> +    NewScriptFile->Argv[0] = StrnCatGrow(&NewScriptFile->Argv[0], NULL,
> NewScriptFile->ScriptName, 0);
> +    for (LoopVar = 1 ; LoopVar < 10 && LoopVar < NewScriptFile->Argc;
> LoopVar++) {
>        ASSERT(NewScriptFile->Argv[LoopVar] == NULL);
>        NewScriptFile->Argv[LoopVar] = StrnCatGrow(&NewScriptFile-
> >Argv[LoopVar], NULL, ShellInfoObject.NewShellParametersProtocol-
> >Argv[LoopVar], 0);
>        if (NewScriptFile->Argv[LoopVar] == NULL) {
> --
> 2.17.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] ShellPkg-Shell App: Provide fully-qualified path to shell scripts
  2018-10-24 18:03 ` Carsey, Jaben
@ 2018-10-25  5:48   ` Ni, Ruiyu
  0 siblings, 0 replies; 3+ messages in thread
From: Ni, Ruiyu @ 2018-10-25  5:48 UTC (permalink / raw)
  To: Carsey, Jaben, Jim.Dailey@dell.com, edk2-devel@lists.01.org

On 10/25/2018 2:03 AM, Carsey, Jaben wrote:
> Looks good to me.
> Ray?
> 
> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

> 
> p.s. Ray if you agree you can RB and I will handle the push.
> 
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> Jim.Dailey@dell.com
>> Sent: Wednesday, October 24, 2018 9:36 AM
>> To: edk2-devel@lists.01.org
>> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
>> Subject: [edk2] [PATCH 2/2] ShellPkg-Shell App: Provide fully-qualified path
>> to shell scripts
>> Importance: High
>>
>> Section 3.6.2 of version 2.2 of the shell specification requires that
>> the first positional argument (i.e. arg 0) of a shell script resolves
>> to "the full path name of the script itself."
>>
>> Ensure that the startup script and any scripts launched by the shell
>> meet this requirement.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Jim Dailey <jim_dailey@dell.com>
>> ---
>>   ShellPkg/Application/Shell/Shell.c | 12 ++++++++++--
>>   1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/ShellPkg/Application/Shell/Shell.c
>> b/ShellPkg/Application/Shell/Shell.c
>> index 6185b6ac80..fe88177d57 100644
>> --- a/ShellPkg/Application/Shell/Shell.c
>> +++ b/ShellPkg/Application/Shell/Shell.c
>> @@ -3,6 +3,7 @@
>>
>>     Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>>     (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.<BR>
>> +  Copyright 2018 Dell Technologies.<BR>
>>     This program and the accompanying materials
>>     are licensed and made available under the terms and conditions of the BSD
>> License
>>     which accompanies this distribution.  The full text of the license may be
>> found at
>> @@ -1275,7 +1276,8 @@ DoStartupScript(
>>
>>     FileStringPath = LocateStartupScript (ImagePath, FilePath);
>>     if (FileStringPath != NULL) {
>> -    Status = RunScriptFile (FileStringPath, NULL, L"",
>> ShellInfoObject.NewShellParametersProtocol);
>> +    FileStringPath = FullyQualifyPath(&FileStringPath);
>> +    Status = RunScriptFile (FileStringPath, NULL, FileStringPath,
>> ShellInfoObject.NewShellParametersProtocol);
>>       FreePool (FileStringPath);
>>     } else {
>>       //
>> @@ -2474,6 +2476,7 @@ RunCommandOrFile(
>>         }
>>         switch (Type) {
>>           case   Script_File_Name:
>> +          CommandWithPath = FullyQualifyPath(&CommandWithPath);
>>             Status = RunScriptFile (CommandWithPath, NULL, CmdLine,
>> ParamProtocol);
>>             break;
>>           case   Efi_Application:
>> @@ -2812,7 +2815,12 @@ RunScriptFileHandle (
>>         DeleteScriptFileStruct(NewScriptFile);
>>         return (EFI_OUT_OF_RESOURCES);
>>       }
>> -    for (LoopVar = 0 ; LoopVar < 10 && LoopVar < NewScriptFile->Argc;
>> LoopVar++) {
>> +    //
>> +    // Put the full path of the script file into Argv[0] as required by section
>> +    // 3.6.2 of version 2.2 of the shell specification.
>> +    //
>> +    NewScriptFile->Argv[0] = StrnCatGrow(&NewScriptFile->Argv[0], NULL,
>> NewScriptFile->ScriptName, 0);
>> +    for (LoopVar = 1 ; LoopVar < 10 && LoopVar < NewScriptFile->Argc;
>> LoopVar++) {
>>         ASSERT(NewScriptFile->Argv[LoopVar] == NULL);
>>         NewScriptFile->Argv[LoopVar] = StrnCatGrow(&NewScriptFile-
>>> Argv[LoopVar], NULL, ShellInfoObject.NewShellParametersProtocol-
>>> Argv[LoopVar], 0);
>>         if (NewScriptFile->Argv[LoopVar] == NULL) {
>> --
>> 2.17.0.windows.1
>>
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel


-- 
Thanks,
Ray


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-25  5:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-24 16:35 [PATCH 2/2] ShellPkg-Shell App: Provide fully-qualified path to shell scripts Jim.Dailey
2018-10-24 18:03 ` Carsey, Jaben
2018-10-25  5:48   ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox