Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
fix possible segmentation fault when connecting (#153)
Browse files Browse the repository at this point in the history
* fix Segmentation fault on lastest libhdfs3

* Allow setting effective user

Plus, specify the type for the sedonc parameter to hdfsBuilderConnect
  • Loading branch information
martindurant committed Feb 27, 2018
1 parent 3fd2c27 commit f6618a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions hdfs3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, host=MyNone, port=MyNone, connect=True, autoconf=True,
of the cluster that can be found in "fs.defaultFS" option.
port : int (8020)
namenode RPC port usually 8020, in HA mode port mast be None
user, ticket_cache, token : str
user, ticket_cache, token, effective_user : str
kerberos things
"""
self.conf = conf.copy() if autoconf else {}
Expand Down Expand Up @@ -120,6 +120,7 @@ def connect(self):
user = conf.pop('user', None)
if user is not None:
_lib.hdfsBuilderSetUserName(o, ensure_bytes(user))
effective_user = ensure_bytes(conf.pop('effective_user', None))

ticket_cache = conf.pop('ticket_cache', None)
if ticket_cache is not None:
Expand All @@ -134,7 +135,7 @@ def connect(self):
ensure_bytes(val)) == 0:
warnings.warn('Setting conf parameter %s failed' % par)

fs = _lib.hdfsBuilderConnect(o)
fs = _lib.hdfsBuilderConnect(o, effective_user)
_lib.hdfsFreeBuilder(o)
if fs:
logger.debug("Connect to handle %d", fs.contents.filesystem)
Expand Down
2 changes: 1 addition & 1 deletion hdfs3/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class hdfsFS(ct.Structure):
hdfsConnectNewInstance.__doc__ = "New structure for connection information"

hdfsBuilderConnect = _lib.hdfsBuilderConnect
hdfsBuilderConnect.argtypes = [ct.POINTER(hdfsBuilder)]
hdfsBuilderConnect.argtypes = [ct.POINTER(hdfsBuilder), ct.c_char_p]
hdfsBuilderConnect.restype = ct.POINTER(hdfsFS)
hdfsBuilderConnect.__doc__ = """Connect to HDFS using the parameters defined by the builder.
Expand Down

0 comments on commit f6618a7

Please sign in to comment.