We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`ls -l` user/group names need justification
`ls -l` does not properly pad the user/group names

**To Reproduce**
Steps to reproduce the behaviour:
1. ssh into a cowrie instance
2. `ls -l` on a directory with more than one user/group
3. the user names and group names don't line up between files

**Expected behaviour**
Nice justified columns of user/group names


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cowrie/commands/ls.py`
Content:
```
1 # Copyright (c) 2009 Upi Tamminen <desaster@gmail.com>
2 # See the COPYRIGHT file for more information
3 
4 from __future__ import absolute_import, division
5 
6 import getopt
7 import os.path
8 import stat
9 import time
10 
11 import cowrie.shell.fs as fs
12 from cowrie.shell.command import HoneyPotCommand
13 from cowrie.shell.pwd import Group, Passwd
14 
15 commands = {}
16 
17 
18 class command_ls(HoneyPotCommand):
19 
20     def uid2name(self, uid):
21         try:
22             return Passwd().getpwuid(uid)["pw_name"]
23         except Exception:
24             return str(uid)
25 
26     def gid2name(self, gid):
27         try:
28             return Group().getgrgid(gid)["gr_name"]
29         except Exception:
30             return str(gid)
31 
32     def call(self):
33         path = self.protocol.cwd
34         paths = []
35         self.showHidden = False
36         self.showDirectories = False
37         func = self.do_ls_normal
38 
39         # Parse options or display no files
40         try:
41             opts, args = getopt.gnu_getopt(self.args, '1@ABCFGHLOPRSTUWabcdefghiklmnopqrstuvwx',
42                                            ['help', 'version', 'param'])
43         except getopt.GetoptError as err:
44             self.write("ls: {}\n".format(err))
45             self.write("Try 'ls --help' for more information.\n")
46             return
47 
48         for x, a in opts:
49             if x in ('-l'):
50                 func = self.do_ls_l
51             if x in ('-a'):
52                 self.showHidden = True
53             if x in ('-d'):
54                 self.showDirectories = True
55 
56         for arg in args:
57             paths.append(self.protocol.fs.resolve_path(arg, self.protocol.cwd))
58 
59         if not paths:
60             func(path)
61         else:
62             for path in paths:
63                 func(path)
64 
65     def get_dir_files(self, path):
66         try:
67             if self.protocol.fs.isdir(path) and not self.showDirectories:
68                 files = self.protocol.fs.get_path(path)[:]
69                 if self.showHidden:
70                     dot = self.protocol.fs.getfile(path)[:]
71                     dot[fs.A_NAME] = '.'
72                     files.append(dot)
73                     dotdot = self.protocol.fs.getfile(os.path.split(path)[0])[:]
74                     if not dotdot:
75                         dotdot = self.protocol.fs.getfile(path)[:]
76                     dotdot[fs.A_NAME] = '..'
77                     files.append(dotdot)
78                 else:
79                     files = [x for x in files if not x[fs.A_NAME].startswith('.')]
80                 files.sort()
81             else:
82                 files = (self.protocol.fs.getfile(path)[:],)
83         except Exception:
84             self.write(
85                 'ls: cannot access %s: No such file or directory\n' % (path,))
86             return
87         return files
88 
89     def do_ls_normal(self, path):
90         files = self.get_dir_files(path)
91 
92         line = [x[fs.A_NAME] for x in files]
93         if not line:
94             return
95         count = 0
96         maxlen = max([len(x) for x in line])
97 
98         try:
99             wincols = self.protocol.user.windowSize[1]
100         except AttributeError:
101             wincols = 80
102 
103         perline = int(wincols / (maxlen + 1))
104         for f in line:
105             if count == perline:
106                 count = 0
107                 self.write('\n')
108             self.write(f.ljust(maxlen + 1))
109             count += 1
110         self.write('\n')
111 
112     def do_ls_l(self, path):
113         files = self.get_dir_files(path)
114 
115         largest = 0
116         if len(files):
117             largest = max([x[fs.A_SIZE] for x in files])
118 
119         for file in files:
120             if file[fs.A_NAME].startswith('.') and not self.showHidden:
121                 continue
122 
123             perms = ['-'] * 10
124             if file[fs.A_MODE] & stat.S_IRUSR:
125                 perms[1] = 'r'
126             if file[fs.A_MODE] & stat.S_IWUSR:
127                 perms[2] = 'w'
128             if file[fs.A_MODE] & stat.S_IXUSR:
129                 perms[3] = 'x'
130             if file[fs.A_MODE] & stat.S_ISUID:
131                 perms[3] = 'S'
132             if file[fs.A_MODE] & stat.S_IXUSR and file[fs.A_MODE] & stat.S_ISUID:
133                 perms[3] = 's'
134 
135             if file[fs.A_MODE] & stat.S_IRGRP:
136                 perms[4] = 'r'
137             if file[fs.A_MODE] & stat.S_IWGRP:
138                 perms[5] = 'w'
139             if file[fs.A_MODE] & stat.S_IXGRP:
140                 perms[6] = 'x'
141             if file[fs.A_MODE] & stat.S_ISGID:
142                 perms[6] = 'S'
143             if file[fs.A_MODE] & stat.S_IXGRP and file[fs.A_MODE] & stat.S_ISGID:
144                 perms[6] = 's'
145 
146             if file[fs.A_MODE] & stat.S_IROTH:
147                 perms[7] = 'r'
148             if file[fs.A_MODE] & stat.S_IWOTH:
149                 perms[8] = 'w'
150             if file[fs.A_MODE] & stat.S_IXOTH:
151                 perms[9] = 'x'
152             if file[fs.A_MODE] & stat.S_ISVTX:
153                 perms[9] = 'T'
154             if file[fs.A_MODE] & stat.S_IXOTH and file[fs.A_MODE] & stat.S_ISVTX:
155                 perms[9] = 't'
156 
157             linktarget = ''
158 
159             if file[fs.A_TYPE] == fs.T_DIR:
160                 perms[0] = 'd'
161             elif file[fs.A_TYPE] == fs.T_LINK:
162                 perms[0] = 'l'
163                 linktarget = ' -> %s' % (file[fs.A_TARGET],)
164 
165             perms = ''.join(perms)
166             ctime = time.localtime(file[fs.A_CTIME])
167 
168             line = '%s 1 %s %s %s %s %s%s' % \
169                 (perms,
170                  self.uid2name(file[fs.A_UID]),
171                  self.gid2name(file[fs.A_GID]),
172                  str(file[fs.A_SIZE]).rjust(len(str(largest))),
173                  time.strftime('%Y-%m-%d %H:%M', ctime),
174                  file[fs.A_NAME],
175                  linktarget)
176 
177             self.write('{0}\n'.format(line))
178 
179 
180 commands['/bin/ls'] = command_ls
181 commands['ls'] = command_ls
182 commands['/bin/dir'] = command_ls
183 commands['dir'] = command_ls
184
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cowrie/commands/ls.py b/src/cowrie/commands/ls.py
--- a/src/cowrie/commands/ls.py
+++ b/src/cowrie/commands/ls.py
@@ -112,9 +112,17 @@
     def do_ls_l(self, path):
         files = self.get_dir_files(path)
 
-        largest = 0
+        filesize_str_extent = 0
         if len(files):
-            largest = max([x[fs.A_SIZE] for x in files])
+            filesize_str_extent = max([len(str(x[fs.A_SIZE])) for x in files])
+
+        user_name_str_extent = 0
+        if len(files):
+            user_name_str_extent = max([len(self.uid2name(x[fs.A_UID])) for x in files])
+
+        group_name_str_extent = 0
+        if len(files):
+            group_name_str_extent = max([len(self.gid2name(x[fs.A_GID])) for x in files])
 
         for file in files:
             if file[fs.A_NAME].startswith('.') and not self.showHidden:
@@ -167,9 +175,9 @@
 
             line = '%s 1 %s %s %s %s %s%s' % \
                 (perms,
-                 self.uid2name(file[fs.A_UID]),
-                 self.gid2name(file[fs.A_GID]),
-                 str(file[fs.A_SIZE]).rjust(len(str(largest))),
+                 self.uid2name(file[fs.A_UID]).ljust(user_name_str_extent),
+                 self.gid2name(file[fs.A_GID]).ljust(group_name_str_extent),
+                 str(file[fs.A_SIZE]).rjust(filesize_str_extent),
                  time.strftime('%Y-%m-%d %H:%M', ctime),
                  file[fs.A_NAME],
                  linktarget)

{"golden_diff": "diff --git a/src/cowrie/commands/ls.py b/src/cowrie/commands/ls.py\n--- a/src/cowrie/commands/ls.py\n+++ b/src/cowrie/commands/ls.py\n@@ -112,9 +112,17 @@\n     def do_ls_l(self, path):\n         files = self.get_dir_files(path)\n \n-        largest = 0\n+        filesize_str_extent = 0\n         if len(files):\n-            largest = max([x[fs.A_SIZE] for x in files])\n+            filesize_str_extent = max([len(str(x[fs.A_SIZE])) for x in files])\n+\n+        user_name_str_extent = 0\n+        if len(files):\n+            user_name_str_extent = max([len(self.uid2name(x[fs.A_UID])) for x in files])\n+\n+        group_name_str_extent = 0\n+        if len(files):\n+            group_name_str_extent = max([len(self.gid2name(x[fs.A_GID])) for x in files])\n \n         for file in files:\n             if file[fs.A_NAME].startswith('.') and not self.showHidden:\n@@ -167,9 +175,9 @@\n \n             line = '%s 1 %s %s %s %s %s%s' % \\\n                 (perms,\n-                 self.uid2name(file[fs.A_UID]),\n-                 self.gid2name(file[fs.A_GID]),\n-                 str(file[fs.A_SIZE]).rjust(len(str(largest))),\n+                 self.uid2name(file[fs.A_UID]).ljust(user_name_str_extent),\n+                 self.gid2name(file[fs.A_GID]).ljust(group_name_str_extent),\n+                 str(file[fs.A_SIZE]).rjust(filesize_str_extent),\n                  time.strftime('%Y-%m-%d %H:%M', ctime),\n                  file[fs.A_NAME],\n                  linktarget)\n", "issue": "`ls -l` user/group names need justification\n`ls -l` does not properly pad the user/group names\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behaviour:\r\n1. ssh into a cowrie instance\r\n2. `ls -l` on a directory with more than one user/group\r\n3. the user names and group names don't line up between files\r\n\r\n**Expected behaviour**\r\nNice justified columns of user/group names\r\n\n", "before_files": [{"content": "# Copyright (c) 2009 Upi Tamminen <desaster@gmail.com>\n# See the COPYRIGHT file for more information\n\nfrom __future__ import absolute_import, division\n\nimport getopt\nimport os.path\nimport stat\nimport time\n\nimport cowrie.shell.fs as fs\nfrom cowrie.shell.command import HoneyPotCommand\nfrom cowrie.shell.pwd import Group, Passwd\n\ncommands = {}\n\n\nclass command_ls(HoneyPotCommand):\n\n    def uid2name(self, uid):\n        try:\n            return Passwd().getpwuid(uid)[\"pw_name\"]\n        except Exception:\n            return str(uid)\n\n    def gid2name(self, gid):\n        try:\n            return Group().getgrgid(gid)[\"gr_name\"]\n        except Exception:\n            return str(gid)\n\n    def call(self):\n        path = self.protocol.cwd\n        paths = []\n        self.showHidden = False\n        self.showDirectories = False\n        func = self.do_ls_normal\n\n        # Parse options or display no files\n        try:\n            opts, args = getopt.gnu_getopt(self.args, '1@ABCFGHLOPRSTUWabcdefghiklmnopqrstuvwx',\n                                           ['help', 'version', 'param'])\n        except getopt.GetoptError as err:\n            self.write(\"ls: {}\\n\".format(err))\n            self.write(\"Try 'ls --help' for more information.\\n\")\n            return\n\n        for x, a in opts:\n            if x in ('-l'):\n                func = self.do_ls_l\n            if x in ('-a'):\n                self.showHidden = True\n            if x in ('-d'):\n                self.showDirectories = True\n\n        for arg in args:\n            paths.append(self.protocol.fs.resolve_path(arg, self.protocol.cwd))\n\n        if not paths:\n            func(path)\n        else:\n            for path in paths:\n                func(path)\n\n    def get_dir_files(self, path):\n        try:\n            if self.protocol.fs.isdir(path) and not self.showDirectories:\n                files = self.protocol.fs.get_path(path)[:]\n                if self.showHidden:\n                    dot = self.protocol.fs.getfile(path)[:]\n                    dot[fs.A_NAME] = '.'\n                    files.append(dot)\n                    dotdot = self.protocol.fs.getfile(os.path.split(path)[0])[:]\n                    if not dotdot:\n                        dotdot = self.protocol.fs.getfile(path)[:]\n                    dotdot[fs.A_NAME] = '..'\n                    files.append(dotdot)\n                else:\n                    files = [x for x in files if not x[fs.A_NAME].startswith('.')]\n                files.sort()\n            else:\n                files = (self.protocol.fs.getfile(path)[:],)\n        except Exception:\n            self.write(\n                'ls: cannot access %s: No such file or directory\\n' % (path,))\n            return\n        return files\n\n    def do_ls_normal(self, path):\n        files = self.get_dir_files(path)\n\n        line = [x[fs.A_NAME] for x in files]\n        if not line:\n            return\n        count = 0\n        maxlen = max([len(x) for x in line])\n\n        try:\n            wincols = self.protocol.user.windowSize[1]\n        except AttributeError:\n            wincols = 80\n\n        perline = int(wincols / (maxlen + 1))\n        for f in line:\n            if count == perline:\n                count = 0\n                self.write('\\n')\n            self.write(f.ljust(maxlen + 1))\n            count += 1\n        self.write('\\n')\n\n    def do_ls_l(self, path):\n        files = self.get_dir_files(path)\n\n        largest = 0\n        if len(files):\n            largest = max([x[fs.A_SIZE] for x in files])\n\n        for file in files:\n            if file[fs.A_NAME].startswith('.') and not self.showHidden:\n                continue\n\n            perms = ['-'] * 10\n            if file[fs.A_MODE] & stat.S_IRUSR:\n                perms[1] = 'r'\n            if file[fs.A_MODE] & stat.S_IWUSR:\n                perms[2] = 'w'\n            if file[fs.A_MODE] & stat.S_IXUSR:\n                perms[3] = 'x'\n            if file[fs.A_MODE] & stat.S_ISUID:\n                perms[3] = 'S'\n            if file[fs.A_MODE] & stat.S_IXUSR and file[fs.A_MODE] & stat.S_ISUID:\n                perms[3] = 's'\n\n            if file[fs.A_MODE] & stat.S_IRGRP:\n                perms[4] = 'r'\n            if file[fs.A_MODE] & stat.S_IWGRP:\n                perms[5] = 'w'\n            if file[fs.A_MODE] & stat.S_IXGRP:\n                perms[6] = 'x'\n            if file[fs.A_MODE] & stat.S_ISGID:\n                perms[6] = 'S'\n            if file[fs.A_MODE] & stat.S_IXGRP and file[fs.A_MODE] & stat.S_ISGID:\n                perms[6] = 's'\n\n            if file[fs.A_MODE] & stat.S_IROTH:\n                perms[7] = 'r'\n            if file[fs.A_MODE] & stat.S_IWOTH:\n                perms[8] = 'w'\n            if file[fs.A_MODE] & stat.S_IXOTH:\n                perms[9] = 'x'\n            if file[fs.A_MODE] & stat.S_ISVTX:\n                perms[9] = 'T'\n            if file[fs.A_MODE] & stat.S_IXOTH and file[fs.A_MODE] & stat.S_ISVTX:\n                perms[9] = 't'\n\n            linktarget = ''\n\n            if file[fs.A_TYPE] == fs.T_DIR:\n                perms[0] = 'd'\n            elif file[fs.A_TYPE] == fs.T_LINK:\n                perms[0] = 'l'\n                linktarget = ' -> %s' % (file[fs.A_TARGET],)\n\n            perms = ''.join(perms)\n            ctime = time.localtime(file[fs.A_CTIME])\n\n            line = '%s 1 %s %s %s %s %s%s' % \\\n                (perms,\n                 self.uid2name(file[fs.A_UID]),\n                 self.gid2name(file[fs.A_GID]),\n                 str(file[fs.A_SIZE]).rjust(len(str(largest))),\n                 time.strftime('%Y-%m-%d %H:%M', ctime),\n                 file[fs.A_NAME],\n                 linktarget)\n\n            self.write('{0}\\n'.format(line))\n\n\ncommands['/bin/ls'] = command_ls\ncommands['ls'] = command_ls\ncommands['/bin/dir'] = command_ls\ncommands['dir'] = command_ls\n", "path": "src/cowrie/commands/ls.py"}], "after_files": [{"content": "# Copyright (c) 2009 Upi Tamminen <desaster@gmail.com>\n# See the COPYRIGHT file for more information\n\nfrom __future__ import absolute_import, division\n\nimport getopt\nimport os.path\nimport stat\nimport time\n\nimport cowrie.shell.fs as fs\nfrom cowrie.shell.command import HoneyPotCommand\nfrom cowrie.shell.pwd import Group, Passwd\n\ncommands = {}\n\n\nclass command_ls(HoneyPotCommand):\n\n    def uid2name(self, uid):\n        try:\n            return Passwd().getpwuid(uid)[\"pw_name\"]\n        except Exception:\n            return str(uid)\n\n    def gid2name(self, gid):\n        try:\n            return Group().getgrgid(gid)[\"gr_name\"]\n        except Exception:\n            return str(gid)\n\n    def call(self):\n        path = self.protocol.cwd\n        paths = []\n        self.showHidden = False\n        self.showDirectories = False\n        func = self.do_ls_normal\n\n        # Parse options or display no files\n        try:\n            opts, args = getopt.gnu_getopt(self.args, '1@ABCFGHLOPRSTUWabcdefghiklmnopqrstuvwx',\n                                           ['help', 'version', 'param'])\n        except getopt.GetoptError as err:\n            self.write(\"ls: {}\\n\".format(err))\n            self.write(\"Try 'ls --help' for more information.\\n\")\n            return\n\n        for x, a in opts:\n            if x in ('-l'):\n                func = self.do_ls_l\n            if x in ('-a'):\n                self.showHidden = True\n            if x in ('-d'):\n                self.showDirectories = True\n\n        for arg in args:\n            paths.append(self.protocol.fs.resolve_path(arg, self.protocol.cwd))\n\n        if not paths:\n            func(path)\n        else:\n            for path in paths:\n                func(path)\n\n    def get_dir_files(self, path):\n        try:\n            if self.protocol.fs.isdir(path) and not self.showDirectories:\n                files = self.protocol.fs.get_path(path)[:]\n                if self.showHidden:\n                    dot = self.protocol.fs.getfile(path)[:]\n                    dot[fs.A_NAME] = '.'\n                    files.append(dot)\n                    dotdot = self.protocol.fs.getfile(os.path.split(path)[0])[:]\n                    if not dotdot:\n                        dotdot = self.protocol.fs.getfile(path)[:]\n                    dotdot[fs.A_NAME] = '..'\n                    files.append(dotdot)\n                else:\n                    files = [x for x in files if not x[fs.A_NAME].startswith('.')]\n                files.sort()\n            else:\n                files = (self.protocol.fs.getfile(path)[:],)\n        except Exception:\n            self.write(\n                'ls: cannot access %s: No such file or directory\\n' % (path,))\n            return\n        return files\n\n    def do_ls_normal(self, path):\n        files = self.get_dir_files(path)\n\n        line = [x[fs.A_NAME] for x in files]\n        if not line:\n            return\n        count = 0\n        maxlen = max([len(x) for x in line])\n\n        try:\n            wincols = self.protocol.user.windowSize[1]\n        except AttributeError:\n            wincols = 80\n\n        perline = int(wincols / (maxlen + 1))\n        for f in line:\n            if count == perline:\n                count = 0\n                self.write('\\n')\n            self.write(f.ljust(maxlen + 1))\n            count += 1\n        self.write('\\n')\n\n    def do_ls_l(self, path):\n        files = self.get_dir_files(path)\n\n        filesize_str_extent = 0\n        if len(files):\n            filesize_str_extent = max([len(str(x[fs.A_SIZE])) for x in files])\n\n        user_name_str_extent = 0\n        if len(files):\n            user_name_str_extent = max([len(self.uid2name(x[fs.A_UID])) for x in files])\n\n        group_name_str_extent = 0\n        if len(files):\n            group_name_str_extent = max([len(self.gid2name(x[fs.A_GID])) for x in files])\n\n        for file in files:\n            if file[fs.A_NAME].startswith('.') and not self.showHidden:\n                continue\n\n            perms = ['-'] * 10\n            if file[fs.A_MODE] & stat.S_IRUSR:\n                perms[1] = 'r'\n            if file[fs.A_MODE] & stat.S_IWUSR:\n                perms[2] = 'w'\n            if file[fs.A_MODE] & stat.S_IXUSR:\n                perms[3] = 'x'\n            if file[fs.A_MODE] & stat.S_ISUID:\n                perms[3] = 'S'\n            if file[fs.A_MODE] & stat.S_IXUSR and file[fs.A_MODE] & stat.S_ISUID:\n                perms[3] = 's'\n\n            if file[fs.A_MODE] & stat.S_IRGRP:\n                perms[4] = 'r'\n            if file[fs.A_MODE] & stat.S_IWGRP:\n                perms[5] = 'w'\n            if file[fs.A_MODE] & stat.S_IXGRP:\n                perms[6] = 'x'\n            if file[fs.A_MODE] & stat.S_ISGID:\n                perms[6] = 'S'\n            if file[fs.A_MODE] & stat.S_IXGRP and file[fs.A_MODE] & stat.S_ISGID:\n                perms[6] = 's'\n\n            if file[fs.A_MODE] & stat.S_IROTH:\n                perms[7] = 'r'\n            if file[fs.A_MODE] & stat.S_IWOTH:\n                perms[8] = 'w'\n            if file[fs.A_MODE] & stat.S_IXOTH:\n                perms[9] = 'x'\n            if file[fs.A_MODE] & stat.S_ISVTX:\n                perms[9] = 'T'\n            if file[fs.A_MODE] & stat.S_IXOTH and file[fs.A_MODE] & stat.S_ISVTX:\n                perms[9] = 't'\n\n            linktarget = ''\n\n            if file[fs.A_TYPE] == fs.T_DIR:\n                perms[0] = 'd'\n            elif file[fs.A_TYPE] == fs.T_LINK:\n                perms[0] = 'l'\n                linktarget = ' -> %s' % (file[fs.A_TARGET],)\n\n            perms = ''.join(perms)\n            ctime = time.localtime(file[fs.A_CTIME])\n\n            line = '%s 1 %s %s %s %s %s%s' % \\\n                (perms,\n                 self.uid2name(file[fs.A_UID]).ljust(user_name_str_extent),\n                 self.gid2name(file[fs.A_GID]).ljust(group_name_str_extent),\n                 str(file[fs.A_SIZE]).rjust(filesize_str_extent),\n                 time.strftime('%Y-%m-%d %H:%M', ctime),\n                 file[fs.A_NAME],\n                 linktarget)\n\n            self.write('{0}\\n'.format(line))\n\n\ncommands['/bin/ls'] = command_ls\ncommands['ls'] = command_ls\ncommands['/bin/dir'] = command_ls\ncommands['dir'] = command_ls\n", "path": "src/cowrie/commands/ls.py"}]}